Visual Studio在多个启动项目之间存在延迟? [英] Visual Studio delay between multiple startup projects?

查看:55
本文介绍了Visual Studio在多个启动项目之间存在延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在解决方案中的启动项目之间增加一些延迟?

how to add some delay between startup projects in solution?

我希望在启动WindowsService的2-3秒后启动Client项目.

I want Client project to be started after 2-3 seconds from starting WindowsService.

我为什么需要这个?

WindowsService运行套接字服务器,而Client运行套接字以连接到服务器.WindowsService的加载速度比客户端慢,这会导致客户端在连接到尚未运行的服务器时出现异常

WindowsService runs socket server and Client runs socket to connect to server. WindowsService loads slowly than Client, and this causes an exception on client side when connecting to server which is not run yet

推荐答案

我可能会在客户端中添加重试机制.这样,它不仅可以在从Visual Studio启动"的情况下提供帮助,而且 在实际客户端连接时服务器恰巧在重新启动的情况下也可以提供帮助.服务器位于更快的计算机上这一事实并不意味着服务器将永远不需要重新启动,是吗?

I would probably add a retry mechanism within the client. That way not only does it help in the "starting up from Visual Studio" case - it also helps if the server happens to be restarting while the real client connects. The fact that the server is on a faster machine doesn't mean the server will never need to restart, does it?

实际上,您可能希望以这种方式添加此重试机制,即使服务器在连接时 重新启动,客户端也可以恢复.当然,这取决于项目的工作.

Indeed, you may well want to add this retry mechanism in such a way that the client can recover even if the server is restarted while it's connected. It depends on what the project is doing, of course.

这篇关于Visual Studio在多个启动项目之间存在延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆