控制台窗口正在消失

时间:2018-03-04 18:00:20

标签: c#

我试图连接到名为Cryptopia的加密货币交易所。 但是当使用以下代码时,控制台窗口会立即消失。 你能帮忙吗?

hapax_legomena_ratio(['James Fennimore Cooper\n', 'Peter, Paul, and Mary\n', 'James Gosling\n'])
>>> 0.7777777777777778

1 个答案:

答案 0 :(得分:1)

您实际上并没有等待MainAsync完成。您必须执行MainAsync().Wait()

之类的操作
Task task = MainAsync();
 // Potentially do some other work here
 task.Wait();

要在上述代码的上下文中显示:

static void Main(string[] args)
{
    Console.WriteLine("Calling main async");
    Console.ReadLine();
    // We must explicitly wait for MainAsync to complete before exiting the application
    MainAsync(args).Wait();
}

重要提示: 在具有同步上下文的环境中执行此类操作(或者它会导致死锁) - 请改用await

相关问题