无法在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 ...
-
一般来说,Node.js如何处理10,000个并发请求?(How, in general, does Node.js handle 10,000 concurrent requests?)[2022-06-26]
如果你必须提出这个问题,那么你可能不太熟悉大多数的Web应用程序/服务。 你可能认为所有的软件都是这样做的: user do an action │ v application start processing action └──> loop ... └──> busy processing end loop └──> send result to user 但是,这不是Web应用程序,或者任何具有数据库作为后端的应用程序的工作原理。 We ... -
node.js如何工作?(How node.js works?)[2023-05-15]
节点是完全事件驱动的。 服务器基本上由一个线程处理一个事件。 一个新的要求是一个事件。 服务器开始处理它,当有一个阻塞的IO操作时,它不会等到它完成,而是注册一个回调函数。 然后服务器立即开始处理另一个事件(也许是另一个请求)。 当IO操作完成时,这是另一种事件,服务器将在处理它(即继续处理请求)时立即执行回调。 所以服务器不需要创建额外的线程或在线程之间切换,这意味着它的开销很少。 如果要充分利用多个硬件内核,只需启动多个node.js实例即可 更新在最底层(C ++代码,而不是Javascript),n ... -
node.js如何处理故意大(和坏)的http请求(node.js how to handle intentionally large (and bad) http requests)[2024-01-10]
您可以限制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 ... -
使用http请求在php旁边使用node.js是否安全?(Is it safe to use node.js next to php using http requests?)[2023-12-09]
这种方法安全吗? 当然。 我的意思是技术上,当然。 它并不比任何单独的技术更不安全。 但是,它确实使您的架构更复杂,可能会导致更多的人为错误和错误或安全问题。 但这更多是关于人类和复杂性而不是技术本身。 在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 ...
-
简单的Node.js服务器无法处理几百个并发请求(Simple Node.js server not able to handle few hundred concurrent requests)[2023-08-05]
您可能需要增加套接字池的值。 尝试: 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) ...