ServerAgent.ProcessEvent method

Lync 2013

Dequeues an event from the server queue and processes it.

Namespace:  Microsoft.Rtc.Sip
Assembly:  ServerAgent (in ServerAgent.dll)

public void ProcessEvent(
	Object notUsed
)

Parameters

notUsed
Type: System.Object

Not used. This value is a placeholder for the parameter required by the ThreadPool.WaitCallback delegate.

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 Dispatch has been called), the signal is received over the wait handle specified by the ServerAgent.WaitHandle property.

The following example demonstrates passing this method to a WaitCallback delegate.

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;
       }
   }
}


Show: