Beispiel #1
0
 public MainWindow()
 {
     InitializeComponent();
     _asyncTaskQueue = new AsyncTaskQueue
     {
         AutoCancelPreviousTask = true,
         UseSingleThread        = true
     };
 }
Beispiel #2
0
        public static async void Test(AsyncTaskQueue taskQueue, int num)
        {
            var result = await taskQueue.ExecuteAsync(async() =>
            {
                Debug.WriteLine("输入:" + num);
                // 长时间耗时任务
                await Task.Delay(TimeSpan.FromSeconds(5));
                return(num * 100);
            });

            Debug.WriteLine($"{num}输出的:" + result);
        }