예제 #1
0
파일: Do.cs 프로젝트: Holofiber/Friday.NET
        private void Run()
        {
            innerTask = Task.Run(async() =>
            {
                while (ShouldContinueWork())
                {
                    try
                    {
                        if (asyncAction != null)
                        {
                            await asyncAction();
                        }
                        action?.Invoke();
                        await Task.Delay(timeSpan, token);
                    }

                    catch (OperationCanceledException)
                    {
                        return;
                    }
                    catch (Exception e)
                    {
                        exceptionAction?.Invoke(e);

                        if (exceptionAction == null)
                        {
                            FridayDebugger.Log(e);
                        }
                    }
                }
            }, token);
        }
예제 #2
0
 /// <summary>
 /// Prevents UnobservedTaskException
 /// </summary>
 public static void AttachDefaultExceptionHandler(this Task task)
 {
     task.ContinueWith(task1 => FridayDebugger.LogFailedTask(task), TaskContinuationOptions.OnlyOnFaulted).ConfigureAwait(false);
 }