BroadcastSystemMessage equivalent???  
Author Message
My-Spot





PostPosted: .NET Base Class Library, BroadcastSystemMessage equivalent??? Top

I'm sorry if this is the wrong place for this...

One of the biggest issues I have had in making the switch to managed code code is finding equivalents to various functions. I have found this... But I would really like it to go a level or two deeper.

For instance, what is the managed equivalent (and compatible version) of BroadcastSystemMessage

Shoot, while I'm at it, what about something that shows equivalents to the other 10,000 unmanaged functions I have used in the past




.NET Development17  
 
 
Peter Ritchie





PostPosted: .NET Base Class Library, BroadcastSystemMessage equivalent??? Top

Certain things aren't considered safe to do. BroadcastSystemMessage is one of them. It's not inherently supported by .NET. If you want to use something like that you'd have to PInvoke it. See http://www.pinvoke.net/default.aspx/user32/BroadcastSystemMessage.html

 
 
My-Spot





PostPosted: .NET Base Class Library, BroadcastSystemMessage equivalent??? Top

Thank you for the link, looks like that is getting very close to what I'm looking for! However, you mention "Certain things aren't considered safe to do. BroadcastSystemMessage is one of them." This may sound like a dumb question, but how do you know what is safe and what isn't It there a magic list somewhere

 
 
nobugz





PostPosted: .NET Base Class Library, BroadcastSystemMessage equivalent??? Top

"Safe" has a well-defined meaning in the .NET framework. That notion has very little to do with P/Invoking some API function. The framework authors probably assumed there are certain things that you have no business having to do in a typical .NET app. That's why they make you jump through hoops to change the system clock. And broadcast a message to every top-level window. And respond to Plug & Pray events. And whatever else they considered either unsafe or not popular enough to wrap in a .NET class.

It certainly doesn't mean you can't do it. Or be prevented from doing it! That's going to take a major OS redesign that is not even close to being considered afaik...


 
 
My-Spot





PostPosted: .NET Base Class Library, BroadcastSystemMessage equivalent??? Top

I guess this explains why .net makes doing some "everyday" things such a pain (or impossible). In this case I simply want another instance of the same program to "talk" with the first instance - and pass a small amount of info. DDE, Mutex, BroadcastSystemMessage, whatever... .net makes doing many things so easy that I guess I was hoping there was an easy .net way to do everything. I feel like MS is pushing us to program with managed .net and at the same time tying our hands with limited functionality. It is a pain to Pinvoke everything... and to do so I figure I'm doing something wrong or "unsafe".

I guess my biggest issue is that I'm not sure where the edge of the .net cliff is. What has been wrapped in a .net class, and what hasn't. Really, I have spent the last couple of months trying to get my mind around .net, clr, managed code, etc. I feel like I have landed on Mars and in all, it makes me want to crawl back to my "old school" C with its fopen(), fprinf(), and BroadcastSystemMessage()... It may have been buggy, but at least I knew I could do everything if I found the right sample code and functions...



 
 
Peter Ritchie





PostPosted: .NET Base Class Library, BroadcastSystemMessage equivalent??? Top

If you're looking for inter-process communiations, there's much better ways of doing it. If your communications includes large amounts of data (more than 32 bits at a time), in .NET the recommended approach is to use .NET Remoting. While .NET Remoting uses the TCP stack for it's communications medium, it can be used to communicate between two processes on the same computer in addition to separate computers.

It may sound like a heavy-weight solution; but using .NET Removing will give you these benefits over using BroadcastSystemMessage:

  • Well documented framework
  • All managed code
  • Well-used API with many examples and samples
  • Safe serialization of data is performed automatically
  • Built-in security and robustness
  • Suppported
  • Built on standard communications framework that accounts for timeouts, retries, etc.
  • Scalable to 2-tier client/server

And avoids such things as:

  • Poorly written client doesn't repsond to message properly compromising/hanging your application
  • incorrect usage of BroadcastSystemMessage compromises entire system
  • Avoids "pinging" all running applications to find your client/server


 
 
My-Spot





PostPosted: .NET Base Class Library, BroadcastSystemMessage equivalent??? Top

Good deal! I will look into it and give it a try. Thanks...