Equivalent to WSAWaitForMultipleEvents in .NET
-
Hi, I've got some C++ code to convert to C# and I'd prefer the C# to be as similar in design to the legacy code as possible (not my original design). Currently, I'm not having much luck finding an equivalent to WSAWaitForMultipleEvents() that lives in the managed world. Also, the current architecture doesn't allow for a higher-level repackaging with a C++/CLI. Could anyone point me towards it if I'm just not seeing it in MSDN after staring at the screen for too long, or alternatively put me out my misery so I know I've just got to go with a rethink and rework and new time estimate. Thanks v. much in advance, Kev
-
Hi, I've got some C++ code to convert to C# and I'd prefer the C# to be as similar in design to the legacy code as possible (not my original design). Currently, I'm not having much luck finding an equivalent to WSAWaitForMultipleEvents() that lives in the managed world. Also, the current architecture doesn't allow for a higher-level repackaging with a C++/CLI. Could anyone point me towards it if I'm just not seeing it in MSDN after staring at the screen for too long, or alternatively put me out my misery so I know I've just got to go with a rethink and rework and new time estimate. Thanks v. much in advance, Kev
How about something like Socket.Select()[^]?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
How about something like Socket.Select()[^]?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
You gave me a brief glimmer of hope there that I hadn't read the docs properly and that it was something that obvious, but no. :( Socket.Select() does only work with sockets. I've given up now to be honest. I'll go with Socket.Select() with an internal control socket that, when data is read from it, is the signal to close down the main socket. Not ideal, but it's a close enough workaround that it's still clear what's happening in the ported code even though the events have been swapped for sockets. As being close and preserving the overall code structure is what I've been asked to do, it's good enough. Thanks very much for the response anyway! Kev
-
You gave me a brief glimmer of hope there that I hadn't read the docs properly and that it was something that obvious, but no. :( Socket.Select() does only work with sockets. I've given up now to be honest. I'll go with Socket.Select() with an internal control socket that, when data is read from it, is the signal to close down the main socket. Not ideal, but it's a close enough workaround that it's still clear what's happening in the ported code even though the events have been swapped for sockets. As being close and preserving the overall code structure is what I've been asked to do, it's good enough. Thanks very much for the response anyway! Kev
In fact I don't know where this idea to look at Socket.Select() comes from. When I read your post and the documentation again, nothing mention socket!?! :confused: Anyway, how about: Semaphore[^], or multiple call to ThreadPool.RegisterWaitForSingleObject[^]?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
Hi, I've got some C++ code to convert to C# and I'd prefer the C# to be as similar in design to the legacy code as possible (not my original design). Currently, I'm not having much luck finding an equivalent to WSAWaitForMultipleEvents() that lives in the managed world. Also, the current architecture doesn't allow for a higher-level repackaging with a C++/CLI. Could anyone point me towards it if I'm just not seeing it in MSDN after staring at the screen for too long, or alternatively put me out my misery so I know I've just got to go with a rethink and rework and new time estimate. Thanks v. much in advance, Kev
lemur wrote:
an equivalent to WSAWaitForMultipleEvents() that lives in the managed world
On Windows, WSAWaitForMultipleEvents is the same as WaitForMultipleObjectsEx(). WaitForMultipleObjectsEx() in .NET is WaitHandle.WaitAny().
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
In fact I don't know where this idea to look at Socket.Select() comes from. When I read your post and the documentation again, nothing mention socket!?! :confused: Anyway, how about: Semaphore[^], or multiple call to ThreadPool.RegisterWaitForSingleObject[^]?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
You're closer with Socket.Select rather than the others which work on WaitHandles. I'll look into getting a WaitHandle-based object associated with a socket so I could use the regular WaitForMultipleObjects but the client's happy with the socket-workaround I told in last mail. Thanks again. K