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()); }
private void SomeEventHandler(object sender, EventArgs args) { string result = await Task.Run(() => new PrintClass().DoWork()); TboxPrint.AppendText(result); }