예제 #1
0
 public void ScheduleBackgroundTask(Func <Task> task, ProgressBarReport progressBarReport)
 {
     lock (_gate)
     {
         _tasks = _tasks ?? new List <Task>();
         _tasks.Add(Task.Run(() => CallBackgroundTask(task, progressBarReport)));
     }
 }
예제 #2
0
        private async Task CallBackgroundTask(Func <Task> task, ProgressBarReport report)
        {
            CurrentReport = report;
            Interlocked.Increment(ref _backgroundTaskCount);
            try
            {
                await task();
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }

            Interlocked.Decrement(ref _backgroundTaskCount);
        }
예제 #3
0
 public void ScheduleForegroundTask(Action task, ProgressBarReport report)
 {
     ScheduleForegroundTask(() => ActionAsEnumerable(task, report));
 }
예제 #4
0
        private static IEnumerable <ProgressBarReport> ActionAsEnumerable(Action task, ProgressBarReport report)
        {
            yield return(report);

            task();
        }