private void SomeEventHandler(object sender, EventArgs args)
 {
     Task.Factory.StartNew(() => new PrintClass().DoWork())
     .ContinueWith(t => TboxPrint.AppendText(t.Result)
                   , CancellationToken.None
                   , TaskContinuationOptions.None
                   , TaskScheduler.FromCurrentSynchronizationContext());
 }
示例#2
0
    private void SomeEventHandler(object sender, EventArgs args)
    {
        string result = await Task.Run(() => new PrintClass().DoWork());

        TboxPrint.AppendText(result);
    }