我试图连接到名为Cryptopia的加密货币交易所。 但是当使用以下代码时,控制台窗口会立即消失。 你能帮忙吗?
hapax_legomena_ratio(['James Fennimore Cooper\n', 'Peter, Paul, and Mary\n', 'James Gosling\n'])
>>> 0.7777777777777778
答案 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