Here is a little something I recorded on my way to China. Took me three days to upload to YouTube
A natural next step in this course on Edge.js is to call node from .Net. We will start with a very simple example of the Hello World type, and then I will do a separate video on using node modules – which might the reason that you would like to do this in the first place. I’m trying to keep the videos show, and since I’m recording this on an airplane on my way to China (audio I ended up recording in China at the airport while waiting for a friend that is arriving from the US 3h later) I’m worried I won’t be able to record everything and get this out on time.
The first thing we are doing is creating a simple console application in C#.
After that we are going to grab the Edge NuGet package from the NuGet gallery, http://www.nuget.org/packages/Edge.js/ , and use the Package Manager Console to grab the package with the cmdlet Install-Package Edge.js
Once it is done downloading we can start using it
First we are going to write a constant which will hold the simple function call- this is just for brevity
Then we will define an async method that returns a Task and accepts a string for the greeting
Inside the method we call Edge.Func() and pass in the string declared earlier as a constant. The returned variable is what holds the output, and passing it in a Console.WriteLine after awaiting it outputs the full greeting to the console.
Before we can actually see anything we need to however call the function, and we do it in Main with a Wait. – you could just fire and move on without the Wait (that itself is a longer discussion). Pass in the greeting in the function, and add a Console.Read(); to make sure the application doesn’t close after executing the function, and run the application.
And that’s it.
More fun examples, where we do useful things coming soon, stay tuned!
Code as always on GitHub: crab and have fun