locked
Process.HasExited RRS feed

  • Question

  • I use the following loop to wait for the end of some previously launched processes:

            For i = StartProgram To p.Length - 1

                While Not proc(i).HasExited
                    Sleep(100)
                End While

            Next

    The problem that I have is that some of the proc(i) processes have changed from Console to WPF apps. These new apps contain windows with websites that I would like to access when the app has ended.

    Before, with the console apps, once the application had ended, the console would close but the website would stay open and The loop above would work well.

    Now, however, with the new WPF apps the loop above only works if I quit the apps programmatically which means losing the website access.

    A workaround is to have each process write to a file a code when it has reached the end and then use a similar loop as above checking with a streamreader for that code. 

    That is very convoluted.

    Any better way to do it?

    The option of writing the new apps in Console form is not an option. The website control, WebView2, is not available for console apps.



    Wednesday, June 17, 2020 3:39 PM

All replies

  • Hi AntSalc,

    We’re doing research on this issue. It might take some time before we get back to you.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 18, 2020 9:52 AM
  • Hi AntSalc,

    According to your description, I have a question to confirm with you.

    >>with the console apps, once the application had ended, the console would close but the website would stay open and The loop above would work well.

    Could you provide more details or some related code about the sentence? It will help us to analzye your problem.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 19, 2020 8:40 AM
  • Hello Xingyu Zhao,

    Thank you for your help.

    Before I was using the Internet Explorer control. I would be able to launch a browser from the console app and as long as I did not close Internet Explorer in that app, the Internet Explorer browser window would stay open after the code has reached End Sub

    Basically, the created IE object would stay open after the console app has exited. Which is the normal behaviour.

    Some example code is below

    Module Module1

        Public WithEvents Wb As New SHDocVw.InternetExplorer

        Public WithEvents Wbe As New SHDocVw.InternetExplorer

        Sub Main()

            

            Dim HTMLDoc As mshtml.HTMLDocument

            Dim iHTMLCol As mshtml.IHTMLElementCollection

            Dim iHTMLEle As mshtml.IHTMLElement

            wb.Visible = False

            wb.Navigate("http://time.is/New_York")


        Private Sub Wbe_DocumentComplete(ByVal pDisp As Object, ByRef URL As Object) Handles Wbe.DocumentComplete

             If pDisp Is wbe.Parent And wbe.ReadyState = SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE Then dnc = False

        Private Sub Wb_DocumentComplete(pDisp As Object, ByRef URL As Object) Handles Wb.DocumentComplete

            If Wb.ReadyState = SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE Then dnc = False

            

        End Sub

    End Module

    Friday, June 19, 2020 11:49 AM
  • Hi AntSalc,

    Thanks for your feedback.

    The Microsoft Edge WebView2 displays the web content in native applications.

    Did you consider using Microsoft Internet Controls in your WPF application like console application?

    For example:

    Besides, for more professional help in WPF, I suggest you post your question in WPF forum.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 22, 2020 9:17 AM
  • I have been using the Microsoft Internet Controls in those applications.

    But the whole purpose is to move away from them and into WebView2.

    It seems it is still early

    Monday, June 22, 2020 3:23 PM