ServerAgent.ProcessEvent
The ProcessEvent method removes an event from the server queue and processes it.
Syntax
[C#]
Copy Code | |
---|---|
public void ProcessEvent( Object notUsed ); |
Syntax
[Visual Basic .NET]
Copy Code | |
---|---|
Public Sub ProcessEvent( _ ByVal notUsed As Object _ ) |
Parameters
Return Values
This method has no return values.
Remarks
This method must be called in order to dispatched 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 Dispatch has been called), the signal is received over the wait handle specified by the ServerAgent.WaitHandle property.
This method implements the ThreadPool.WaitCallback delegate, making it easy for applications to use the built-in system thread pool.
Example Code
The following example demonstrates passing this method to a WaitCallback delegate.
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; } } } |
Requirements
Redistributable: Requires Microsoft Lync Server 2010
Namespace:Microsoft.Rtc.Sip
Assembly: ServerAgent (in ServerAgent.dll)