ServerAgent.ProcessEvent(Object) method

 
Microsoft Office Live Communications Server 2005 with SP1

ServerAgent.ProcessEvent

The ProcessEvent method removes an event from the server queue and processes it.

[C#]public void ProcessEvent(ObjectnotUsed);
[Visual Basic .NET]Public Sub ProcessEvent( _
  ByVal notUsed As Object _
)

Parameters

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

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.

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 Office Live Communications Server 2005 with SP1.
Namespace: Microsoft.Rtc.Sip
Assembly: ServerAgent (in ServerAgent.dll)

See Also

ServerAgent

  
  What did you think of this topic?
  © 2008 Microsoft Corporation. All rights reserved.