title: Self updating application in vb.net
body: <p>I want my application to self-update if there is a different size executable available on the remote server. The problem I got is that when I kill the process to replace the application executable, nothing more happends - nothing more is executing after the <code>eprocess.Kill()</code> even though I am trying to freeze the thread during the file replacement process. Is there something I am doing wrong?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>            Dim Request As System.Net.WebRequest
              Dim Response As System.Net.WebResponse
              Dim FileSize As Integer
              Request = Net.WebRequest.Create("http://mywebsite.com/File.exe")
              Request.Method = Net.WebRequestMethods.Http.Get
              Response = Request.GetResponse
              FileSize = Response.ContentLength
              Dim mySize As New IO.FileInfo(Application.ExecutablePath)
              If FileSize &lt;&gt; mySize.Length Then                    If File.Exists(tempPath &amp; "\File_tmp.exe") Then
                      File.Delete(tempPath &amp; "\File_tmp.exe")
                  End If
                  Patcher.DownloadFileAsync(New Uri("http://mywebsite.com/File.exe"), tempPath &amp; "\File_tmp.exe") 'Patcher is defined before, you might think that its not working, but this is just a piece of code, and the new file is downloading properly. The described problem is 
                  While Patcher.IsBusy
                      Threading.Thread.Sleep(100)
                  End While
  
                  Do While True
                      For Each eprocess As Process In Process.GetProcesses
                          If eprocess.ProcessName = "MyApplication" Then
                              eprocess.Kill()
                          End If
                      Next
                      File.Delete(Application.ExecutablePath)
                      'Copy downloaded file to the application executable path directory
                      File.Copy(tempPath &amp; "\File_tmp.exe", Application.ExecutablePath)
                      Threading.Thread.Sleep(30) 'freeze thread...
                  Loop
              End If
  </code></pre>