Exemple #1
0
        public static AsynResult CreateSuccess(string msg = "")
        {
            var result = new AsynResult();

            result.Message = msg;
            result.Success = true;
            return(result);
        }
Exemple #2
0
        public static AsynResult CreateUnsuccress(Exception ex)
        {
            var result = new AsynResult();

            result.Exception = ex;
            result.Message   = ex.Message;
            result.Success   = false;
            return(result);
        }
Exemple #3
0
        public static void QueueTask(Action action, Action <AsynResult> callback)
        {
            var task = new Task(action);

            task.ContinueWith(t => callback(AsynResult.CreateUnsuccress(t.Exception)),
                              TaskContinuationOptions.NotOnRanToCompletion);
            task.ContinueWith(t => callback(AsynResult.CreateSuccess()), TaskContinuationOptions.OnlyOnRanToCompletion);
            allTasks.Enqueue(task);
            sync.Set();
        }