Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27395

VS 2010 [SOLVED]Multithreading help,

$
0
0
Hey guys,

I am having a problem with multithreading, what im trying to do with it is uploading a picture over the webclient function.
It's uploading the file and everything, but it doesnt go to the webclient.uploadcompleted while it did go to that without using multithreading.
Codes I am using.

Code:

Dim thread As System.Threading.Thread
Code:

thread = New System.Threading.Thread(AddressOf ThreadTask)
    thread.Start()

Code:

Private Sub ThreadTask()

  Dim filename As String = ""
  Regiondrag.CheckURL("websitehere(dontwannashowmysitename)" + Regiondrag.TextBox1.Text + ".png")
  filename = Regiondrag.TextBox1.Text + ".png"
  sc.captureActiveWindow.Save(filename, Imaging.ImageFormat.Png)
  webclient.Credentials = New Net.NetworkCredential("id", "pass")
  webclient.UploadFileAsync(New Uri("websitehere(dontwannashowmysitename)" + New IO.FileInfo(filename).Name), filename)
  TextBox1.Text = "websitehere(dontwannashowmysitename)" + filename
  TextBox2.text = filename

    End Sub

And this is the code that's not appearing with multhithreading.
(the uploadfilecompleted code)

Code:

Dim fileName As String = ""
  fileName = Regiondrag.TextBox1.Text + ".png"
  Clipboard.SetText(TextBox1.Text)
  System.Media.SystemSounds.Asterisk.Play()
  ni1.BalloonTipIcon = ToolTipIcon.Info
  ni1.BalloonTipTitle = ("Random")
  ni1.BalloonTipText = ("The picture has been succesfully uploaded! Simply press ctrl + v to share it!")
  ni1.ShowBalloonTip(2000)
  My.Computer.FileSystem.DeleteFile(TextBox2.Text)
  picturehistory.ListBox1.Items.Add("websitehere(dontwannashowmysitename)" + TextBox2.Text)


Viewing all articles
Browse latest Browse all 27395

Trending Articles