首页 \ 问答 \ 无法在ShowMessageAsync上使用await(Can't use await on ShowMessageAsync)

无法在ShowMessageAsync上使用await(Can't use await on ShowMessageAsync)

我正在使用Mahapp并且我正在尝试等待对话框的结果,但是编译器强调了ShowMessageAsync并显示了我:

当前上下文中不存在ShowMessageAsync

这是代码:

private async void ShowMessageBox(object sender, RoutedEventArgs e)
{
    var result = await ShowMessageAsync("Hello!", "Welcome to the world of metro!", 
        MahApps.Metro.Controls.MessageDialogStyle.AffirmativeAndNegative);
    if (result == MessageDialogResult.Affirmative)
    {
        this.ShowMessageAsync("Result", "You said: OK");
    }
    else
    {
        this.ShowMessageAsync("Result", "You said: CANCEL");
    }
}

I'm using Mahapp and I'm trying to wait for the result of the dialog, but the compiler underlined ShowMessageAsync and display me:

ShowMessageAsync doesn't exist in the current context

this is the code:

private async void ShowMessageBox(object sender, RoutedEventArgs e)
{
    var result = await ShowMessageAsync("Hello!", "Welcome to the world of metro!", 
        MahApps.Metro.Controls.MessageDialogStyle.AffirmativeAndNegative);
    if (result == MessageDialogResult.Affirmative)
    {
        this.ShowMessageAsync("Result", "You said: OK");
    }
    else
    {
        this.ShowMessageAsync("Result", "You said: CANCEL");
    }
}

原文:https://stackoverflow.com/questions/37319540
更新时间:2023-11-29 19:11

最满意答案

您可能需要增加套接字池的值。 尝试:

my_http.globalAgent.maxSockets = Infinity //或一些合理的数字......


You may need to increase the value for socket pooling. Try:

my_http.globalAgent.maxSockets = Infinity // or some reasonable number...

相关问答

更多
  • Nginx作为前端服务器,在这种情况下将请求代理到node.js服务器。 因此,您需要为节点设置一个nginx配置文件。 这是我在Ubuntu的框中所做的: 在/etc/nginx/sites-available/创建文件yourdomain : vim /etc/nginx/sites-available/yourdomain 你应该有这样的东西: # the IP(s) on which your node server is running. I chose port 3000. upstream ...
  • 如果你必须提出这个问题,那么你可能不太熟悉大多数的Web应用程序/服务。 你可能认为所有的软件都是这样做的: user do an action │ v application start processing action └──> loop ... └──> busy processing end loop └──> send result to user 但是,这不是Web应用程序,或者任何具有数据库作为后端的应用程序的工作原理。 We ...
  • 节点是完全事件驱动的。 服务器基本上由一个线程处理一个事件。 一个新的要求是一个事件。 服务器开始处理它,当有一个阻塞的IO操作时,它不会等到它完成,而是注册一个回调函数。 然后服务器立即开始处理另一个事件(也许是另一个请求)。 当IO操作完成时,这是另一种事件,服务器将在处理它(即继续处理请求)时立即执行回调。 所以服务器不需要创建额外的线程或在线程之间切换,这意味着它的开销很少。 如果要充分利用多个硬件内核,只需启动多个node.js实例即可 更新在最底层(C ++代码,而不是Javascript),n ...
  • 您可以限制http请求大小。 这是您可以使用的中间件。 https://github.com/senchalabs/connect/blob/master/lib/middleware/limit.js http://www.senchalabs.org/connect/middleware-limit.html PS可能与node.js中的最大请求长度重复 要获取node.js中的IP地址,可以尝试request.connection.remoteAddress 。 You can limit the h ...
  • 这种方法安全吗? 当然。 我的意思是技术上,当然。 它并不比任何单独的技术更不安全。 但是,它确实使您的架构更复杂,可能会导致更多的人为错误和错误或安全问题。 但这更多是关于人类和复杂性而不是技术本身。 在node.js服务器上执行http请求以从数据库发送/接收数据时是否存在安全风险? 不,不超过任何其他后端技术。 它位于Web服务器后面,运行可能访问或不访问数据库并返回响应的代码。 很多生产网站都在运行node.js而没有任何安全问题。 在PHP网站旁边运行node.js是一个好主意,还是应该纯粹在no ...
  • 最后,我发现我的问题是Math.random()的结果有时会导致无限循环发生。 我很高兴我很容易理解这一点。 In the end, I found my issue was that the result of a Math.random() sometimes resulted in an infinite loop occurring. I am glad it was so easy for me to figure this out.
  • 那么答案就是两种方式,客户端应该在它们的最后建立并发逻辑,并且允许node.js成为多进程,这样node.js运行时就可以利用多核心系统。 Well the answer is both ways , the client should model the concurrent logic on their end, and allow node.js to to be multi process, this way the node.js runtime will take advantage of mu ...
  • 请求R2将在5秒后(一旦R1完成)或两者( R1和R2 )将以循环方式运行? 是的,只有在R1完成后,如果R1是同步的,R2才会被占用。 总之,你可以google nodejs event loop 。 有很多很棒的文章解释了Node.js如何使用事件循环来处理请求。 事件循环允许Node.js执行非阻塞I / O操作 - 尽管JavaScript是单线程的 - 通过尽可能将操作卸载到系统内核。 (来源: https : //nodejs.org/en/docs/guides/event-loop-time ...
  • 您可能需要增加套接字池的值。 尝试: my_http.globalAgent.maxSockets = Infinity //或一些合理的数字...... You may need to increase the value for socket pooling. Try: my_http.globalAgent.maxSockets = Infinity // or some reasonable number...
  • Node.js是否逐个处理客户端请求? 是和否.node.js运行您的JS单线程。 这意味着在任何给定时间只运行一个JS执行线程。 所以,如果您有两个这样的请求: // don't use this in real code, it's to simulate a point function spin(t) { var start = Date.now(); while (Date.now() < start + t) {} } app.post("/route1", req, res) ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。