I've been away from .NET desktop programming for some time, while drinking the Node.js koolaid. There are some parts of Node.js I find easy to work with. In particular, I like the simplicity of the threading model, and that I can have a few of the benefits of a multithreaded application while only writing code to keep track of a single thread.
Now, I have a need to write a multi-threaded application in .NET, and it occurred to me that there is no reason I cannot use a similar threading model that is used to build Node.js applications. In particular, I want to:
Does such a framework for this threading model already exist within, or for .NET applications? If not, are there parts of .NET that already support or handle some of the functionality that I am seeking?
ASP.Net is an open source web application framework created by Microsoft. Node. js is an open-source, cross platform JavaScript run-time environment that executes JavaScript code on server-side. ASP.net can be utilized to a modern era site by utilizing web shapes Html 5, JavaScript, CSS.
NET Core has an easier time working with CPU-intensive tasks and rendering static pages since the in-built IIS server kernel caching makes this process very straightforward. Therefore, . NET core vs node.
NET Core is definitely a winner in this category. The security and reliability the platform provides make it a great option to create robust software with C# language. Node. js is more reliable for complex enterprise software developed with TypeScript than on its own.
It is single threaded because of the way JavaScript language executes and the fact that node has it's execution happen in event loop. Wherein the above code works on a single thread ( or main thread) .
As others have mentioned, async
/ await
is an excellent choice for .NET. In particular:
Task
/ Task<T>
/ TaskCompletionSource<T>
are analogous to JavaScript's Deferred
/ Promise
/ Future
.async
/ await
. async
allows you to write your methods as though they were synchronous, and under the hood it breaks them up into continuations wherever there's an await
. So you don't have to use continuation passing style.Task.Run
. However, the standard pattern for .NET is to have the background operation compute and return a single value, instead of having continuous bidirectional messaging with the main thread.I recommend you start with my async
/ await
intro post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With