예제 #1
0
파일: Utility.cs 프로젝트: yply/HomeGenie
 internal static Thread RunAsyncTask(AsyncFunction functionBlock)
 {
     var asyncTask = new Thread(() =>
     {
         try
         {
             functionBlock();
         }
         catch (Exception ex)
         {
             HomeGenieService.LogError(Domains.HomeAutomation_HomeGenie, "Service.Utility.RunAsyncTask", ex.Message, "Exception.StackTrace", ex.StackTrace);
         }
     });
     asyncTask.Start();
     return asyncTask;
 }
예제 #2
0
        public static Thread RunAsyncTask(AsyncFunction fnblock)
        {
            Thread at = new Thread(new ThreadStart(() =>
            {
                try
                {
                    fnblock();
                }
                catch (Exception ex)
                {
                    HomeGenieService.LogEvent(Domains.HomeAutomation_HomeGenie, "Service.Utility.RunAsyncTask", ex.Message, "Exception.StackTrace", ex.StackTrace);
                }
            }));

            at.Start();
            return(at);
        }
예제 #3
0
        public static AsyncThread Borrow(AsyncFunction function)
        {
            AsyncThread thread = null;

            lock (mainLock)
            {
                if (queue.Count > 0)
                {
                    thread = queue[0];
                    queue.RemoveAt(0);
                }
            }
            if (thread == null)
            {
                thread = new AsyncThread();
            }
            thread.function = function;
            thread.wait.Set();
            return(thread);
        }
예제 #4
0
 protected ActionResult None(
     AsyncFunction afterCompletion = null,
     bool awaitCallback            = true)
 => new NoResult(afterCompletion, awaitCallback);
예제 #5
0
 protected ActionResult Ok(
     AsyncFunction logic,
     bool awaitLogic = true)
 => new OkResult(logic, awaitLogic);
예제 #6
0
 public NoResult(AsyncFunction afterCompletion = null, bool awaitCallback = true)
 {
     _after         = afterCompletion;
     _awaitCallback = awaitCallback;
 }