Sign in to follow this  
faculaganymede

[.net] C# equivalent to signal() interrupt handling

Recommended Posts

for the most part, delegates and events are used to deal with "signal" like behavior. Null pointer references and other exceptional cases are dealt with via try..catch blocks... is that what you are looking for?

Share this post


Link to post
Share on other sites
I get the impression from your last handful of questions that you are trying to port some C/C++ code to C#. If thats the case, you are going about it the wrong way.

If I recall correctly, you asked about ferror, which isnt relevent anymore to non C++ devs, you asked about direct bit manipulation in a struct ( aka int myValue : 5; ) which is barely relevant in C coding anymore let alone C++.

All I am saying is you might want to take a different approach. Doing a direct translation from one language to another is almost always a surefire way to fail. This is why so many "benchmarks" of ported C code to other languages are just frankly bad. Each language offers a different pattern which you should learn.

As the above poster said, delegates and events are ( in C# ) much better ways to deal with things in C# that coming up with a signal() equiv. If you keep down the path you are following, you will quickly come to the conclusion that C# is a crappy language based on the fact it doesnt perform as you expected. Not to mention, you havent even started to explore the advantages C# has to offer. Much as treating C++ as a better C was a bad idea in the day, treating C# as a better C++ is an even worse idea.

Share this post


Link to post
Share on other sites
I may be wrong, but interrupts are hard to handle in languages like Java and C#. When the OS sends a signal to your application, the virtual machine will receive the signal, not the app. The virtual machine then does whatever it wants to, you don't have much control over that.

EDIT: actually, catching Ctrl+C and the like is possible in .NET. Take a look at this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this