Using Task.wait() application hangs and never returns

后端 未结 2 1623
庸人自扰
庸人自扰 2021-01-11 15:36

I am new to C# and using Task. I was trying to run this application but my application hangs every time. When I am adding task.wait(), it keeps wai

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 16:00

    You aren't actually running the task. Debugging and checking task.TaskStatus would show this.

    // this should help
    task.Start();
    
    // ... or this:
    Task.Wait(Task.Factory.StartNew(RetrieveFormatedAddress("51.962146", "7.602304")));
    

    Though if you're blocking, why start another thread to begin with?

提交回复
热议问题