In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to wait for the implementation process in C#. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
In the development of C #, it is sometimes necessary to execute external exe or bat programs, and then proceed to the next step according to the results generated by the corresponding programs.
Process class is used for external exe or bat program execution in C #. After the program execution is completed, there are events that can carry out the next operation. However, first, you need to set the EnableRaisingEvents property of process to true in order to respond to the completion event of the exe program. The response to the event is to use the Exited event of process. In the event code, proceed to the next step.
After executing the Start of the process, the main thread does not stop, but continues to execute. When the main thread also needs to wait, use the AutoResetEvent class to let the main thread wait. Define it in the global variable, passing in the parameter false, which causes the thread to block waiting.
AutoResetEvent is one of the simple synchronization methods for. Net threads.
AutoResetEvent mEvent = new AutoResetEvent (false)
After executing the Start, use the WaitOne function of AutoResetEvent to force the thread to wait, and the passed parameters can be added with a timeout to prevent unlimited waiting.
MEvent.WaitOne (TimeSpan.FromMinutes (15))
In the Exited event, after the execution is complete, the Set function is used to make the waiting process continue to execute so that the execution after waiting for completion is achieved.
MEvent.Set ()
The above is how to wait for the execution process in C# shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.