简体   繁体   English

在计算机重新启动时自动重新启动应用程序会挂起应用程序

[英]Auto restart of Application at machine restart hangs the application

I have a windows application developed in c#, starts automatically everyday when machine starts. 我有一个用c#开发的Windows应用程序,每天在计算机启动时自动启动。 By using this windows c# application we are launching an html application to show all the details which reads from this c# application. 通过使用此Windows c#应用程序,我们将启动html应用程序以显示从该c#应用程序读取的所有详细信息。 And this windows application before launches html, reads updated data from server if any available. 并且此Windows应用程序在启动html之前会从服务器读取更新的数据(如果有)。 My issue is when machine starts application also starts and unable to connect to server and goes idle and launches html application and the html application will not be able to communicate and get any data from the windows application. 我的问题是,当计算机启动时,应用程序也将启动,并且无法连接到服务器并进入空闲状态,并启动html应用程序,而html应用程序将无法通信并从Windows应用程序获取任何数据。

But when manually again stop and start the windows application it start connect to server and launch html with proper data. 但是,当再次手动停止并启动Windows应用程序时,它将开始连接到服务器并使用适当的数据启动html。

In registry settings we have give winlogon as c:\\myapplication.exe. 在注册表设置中,我们将winlogon命名为c:\\ myapplication.exe。 Is there any way to make my c# application should wait until the machine starts completely and load all network connections in the machine and later the application starts. 有什么方法可以让我的c#应用程序等待机器完全启动并加载机器中的所有网络连接,然后再启动应用程序。

Any suggestions. 有什么建议么。

Regards Sangeetha 关于Sangeetha

In this situation, I'd Check the connectivity of the system with server before launching the html page and do it every second or two. 在这种情况下,我将在启动html页面之前检查系统与服务器的连通性,并每隔一两秒钟进行一次。 Once I get the connectivity, I'd call the html page to display whatever is required. 获得连接后,我将调用html页面以显示所需的内容。

There are various options to achieve your result: 有多种选择可实现您的结果:

  1. Use Task Scheduler . 使用任务计划程序 The newer version of the task schedule has delay start a task function.Simply set it to execute your 'apps' ON LOGON with different delays. 较新版本的任务计划具有延迟启动任务功能的功能,只需将其设置为以不同的延迟执行您的``应用程序''登录即可。
  2. If your C# application is exposed as service , you could delay load the service with depends on 如果您的C#应用​​程序公开为service ,则可以延迟加载服务,具体取决于

    • Click Start, click Run, and enter regedit. 单击开始,单击运行,然后输入regedit。
    • Expand to the following key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\ 展开到以下项:HKEY_LOCAL_MACHINE \\ SYSTEM \\ CurrentControlSet \\ Services \\
    • Right-click the service that you are trying to set a dependency for and select New -> Multi-string Value. 右键单击您要为其设置依赖项的服务,然后选择“新建”->“多字符串值”。
    • Rename the new value to DependOnService. 将新值重命名为DependOnService。
    • Double-click the DependOnService value and enter the dependent service name (from above) into the Value Data: field and click OK. 双击DependOnService值,然后在“数值数据:”字段中输入从属服务名称(从上方),然后单击“确定”。
    • Close the registry editor. 关闭注册表编辑器。
    • Restart the server. 重新启动服务器。
    • Source 资源

3.You could use free program like Start Up Delayer to delay your program 3.您可以使用启动延迟器之类的免费程序来延迟程序

4.You could create an infinite loop in your c# program and break once all your dependencies are loaded. 4.您可以在c#程序中创建一个无限循环 ,并在加载所有依赖项后中断 Eg checking your are able to connect to the server and so on. 例如,检查您是否能够连接到服务器等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM