Dequeues an event from the server queue and processes it.
Assembly: ServerAgent(in ServerAgent.dll)
Syntax
Visual Basic (declaration) |
---|
Public Sub ProcessEvent ( _ notUsed As Object _ ) |
Visual Basic (usage) |
---|
Dim instance As ServerAgent Dim notUsed As Object instance. ProcessEvent( notUsed) |
C# |
---|
public void ProcessEvent( Object notUsed ) |
Parameters
- notUsed
- Type:
System
.
.
::
.
.
Object
Not used. This value is a placeholder for the parameter required by the ThreadPool.WaitCallbackdelegate.
Remarks
This method implements the [ThreadPool.WaitCallback] delegate to make it easy for applications to use the built-in system thread pool.
This method must be called in order to dispatch messages to
their corresponding event handlers (the methods registered with the
respective MSPL
Dispatch
calls). When a server event is available for processing (a
message has arrived and
Dispatchhas been called), the signal is
received over the wait handle specified by the
The following example demonstrates passing this method to a WaitCallbackdelegate.
Copy code | |
---|---|
public void LCServerEventHandler(ServerAgent sa) { ManualResetEvent autoResetEvent = new ManualResetEvent(false); WaitHandle[] handleArray = new WaitHandle[] { myAppServerAgent.WaitHandle, manualResetEvent }; WaitCallback waitCallback = new WaitCallback(myAppServerAgent.ProcessEvent); while (true) { int signaledEvent = WaitHandle.WaitAny(handleArray); if (signaledEvent == 0) // The server event wait handle (index = 0) in handleArray was signaled { // Schedule a worker thread to process the server event try { if (!ThreadPool.QueueUserWorkItem(waitCallBack)) { Console.WriteLine("QueueUserWorkItem fails, quitting."); return; } } catch (Exception e) { Console.WriteLine("Unexpected exception: {0}\n{1}", e.Message, e.StackTrace); } } else // Manual reset event handle (index = 1) in handle array was signaled { Console.WriteLine("Quit handle signaled, worker will quit now\n"); break; } } } |