예제 #1
0
파일: HeavyLoad.cs 프로젝트: geosohal/Mmo
 private static void ThreadPoolEnqueue(Client client, Action action)
 {
     ThreadPool.QueueUserWorkItem(
         o =>
     {
         try
         {
             action();
         }
         catch (Exception e)
         {
             client.HandleException(e);
         }
     });
 }
예제 #2
0
        /////// <summary>
        /////// The receive event.
        /////// </summary>
        /////// <param name="client">
        /////// The client.
        /////// </param>
        /////// <param name="eventCode">
        /////// The event code.
        /////// </param>
        /////// <param name="checkAction">
        /////// The check action.
        /////// </param>
        /////// <returns>
        /////// </returns>
        ////private static EventData ReceiveEvent(Client client, Code eventCode, Func<EventData, bool> checkAction)
        ////{
        ////    BeginReceiveEvent(client, eventCode, checkAction);
        ////    return EndReceiveEvent(client);
        ////}

        /////// <summary>
        /////// The receive event.
        /////// </summary>
        /////// <param name="client">
        /////// The client.
        /////// </param>
        /////// <param name="eventCode">
        /////// The event code.
        /////// </param>
        /////// <returns>
        /////// </returns>
        ////private static EventData ReceiveEvent(Client client, Code eventCode)
        ////{
        ////    return ReceiveEvent(client, eventCode, d => true);
        ////}

        /////// <summary>
        /////// The receive operation response.
        /////// </summary>
        /////// <param name="client">
        /////// The client.
        /////// </param>
        /////// <param name="operationCode">
        /////// The operation code.
        /////// </param>
        /////// <returns>
        /////// </returns>
        ////private static EventData ReceiveOperationResponse(Client client, OperationCode operationCode)
        ////{
        ////    Func<EventData, bool> checkAction =
        ////        d => (byte)d.Parameters[(short)ParameterCode.OperationCode] == (byte)operationCode;
        ////    EventData data = ReceiveEvent(client, EventCode.OperationSuccess, checkAction);
        ////    var eventCode = (EventCode)(byte)data.Code;
        ////    Assert.IsTrue(eventCode == EventCode.OperationSuccess || eventCode == EventCode.OperationError);
        ////    Assert.AreEqual((OperationCode)(byte)data.Parameters[(short)ParameterCode.OperationCode], operationCode);
        ////    return data;
        ////}

        /// <summary>
        /// The thread pool enqueue.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="action">
        /// The action.
        /// </param>
        private static void ThreadPoolEnqueue(Client client, Action action)
        {
            ThreadPool.QueueUserWorkItem(
                o =>
                {
                    try
                    {
                        action();
                    }
                    catch (Exception e)
                    {
                        client.HandleException(e);
                    }
                });
        }