Exemplo n.º 1
0
        /// <summary>
        /// Schedules the error to be e-mailed asynchronously.
        /// </summary>
        /// <remarks>
        /// The default implementation uses the <see cref="ThreadPool"/>
        /// to queue the reporting.
        /// </remarks>

        protected virtual void ReportErrorAsync(Error error)
        {
            if (error == null)
            {
                throw new ArgumentNullException("error");
            }

            //
            // Schedule the reporting at a later time using a worker from
            // the system thread pool. This makes the implementation
            // simpler, but it might have an impact on reducing the
            // number of workers available for processing ASP.NET
            // requests in the case where lots of errors being generated.
            //

            ThreadPool.QueueUserWorkItem(new WaitCallback(ReportError), error);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Raises the <see cref="E:ClientSessionTerminated"/> event.
 /// </summary>
 /// <param name="args">The <see cref="LoginEventArgs"/> instance containing the event data.</param>
 protected void OnClientSessionTerminated(LoginEventArgs args)
 {
     if (ClientSessionTerminated != null)
     {
         // fire event handlers asynchronously
         ThreadPool.QueueUserWorkItem(_ =>
         {
             try
             {
                 ClientSessionTerminated?.Invoke(this, args);
             }
             catch (Exception ex)
             {
                 Trace.WriteLine("Warning: ClientSessionTerminated event handler has thrown" +
                                 " an exception of type {0}: {1} {2}", ex.GetType(), ex.Message, ex.StackTrace);
             }
         });
     }
 }
 virtual public void SetMaxThreads(int workerThreads, int iocpThreads)
 {
     SThreadPool.SetMaxThreads(workerThreads, iocpThreads);
 }
 virtual public void GetMaxThreads(out int workerThreads, out int iocpThreads)
 {
     SThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
 }
 virtual public bool QueueUserWorkItem(WaitCallback callback, object state)
 {
     return(SThreadPool.QueueUserWorkItem(callback, state));
 }
 virtual public bool QueueUserWorkItem(WaitCallback callback)
 {
     return(SThreadPool.QueueUserWorkItem(callback));
 }
 virtual public RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callback, object state, long timeOutInterval, bool executeOnlyOnce)
 {
     return(SThreadPool.UnsafeRegisterWaitForSingleObject(waitObject, callback, state, timeOutInterval, executeOnlyOnce));
 }