Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 faculaganymede   Members   -  Reputation: 145

Like
0Likes
Like

Posted 18 October 2006 - 02:07 PM

C# gurus, In C/C++, there's function: signal() -- used to set interrupt signal handling. What is the C# equivalent?

Sponsor:

#2 kanato   Members   -  Reputation: 568

Like
0Likes
Like

Posted 18 October 2006 - 04:00 PM

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?

#3 Serapth   Crossbones+   -  Reputation: 5594

Like
0Likes
Like

Posted 18 October 2006 - 04:21 PM

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.

#4 deathkrush   Members   -  Reputation: 350

Like
0Likes
Like

Posted 18 October 2006 - 05:15 PM

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.

#5 faculaganymede   Members   -  Reputation: 145

Like
0Likes
Like

Posted 19 October 2006 - 09:09 AM

Thanks all, for your replies and comments.


[Edited by - faculaganymede on October 19, 2006 7:09:29 PM]




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS