我正在使用Task来创建并在不同的线程上执行一些操作,一旦操作完成,我还会调用回调函数。
System.Threading.Tasks.Task.Factory.StartNew(() =>
this._httpService.CreateRecord(new Uri(Configuration.Current.CreateRecordUrl), httpObj)).ContinueWith(
(response) =>
{
if (!response.IsFaulted)
{
if (httpObj.CallBack != null)
{
httpObj.CallBack(response.Result);
}
}
else {
this._logger.Error("There was some error which causes the task to fail");
}
});
我的控制台应用程序的主线程不会等待任务线程完成,因为它是后台线程。如何将任务线程变成前台线程?
谢谢。