[Source Code] Multithreading example

Posts 1–14 of 14 · Page 1 of 1
[Source Code] Multithreading example
I'm not going to make a tutorial about it, but I attached an example program that uses multithreading to show you how useful it is.



Virusscan:
Virus total
Jotti

Source code:

[php]
Public Class frmMain
#Region "All the code used Without multithreading"
Private Sub btnFreezeWithoutMultithreading_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFreezeWithoutMultithreading.Click
Dim MsgBoxAnswer As String = MsgBox("Freezing the thread will make the application freeze for 5 seconds." & vbCrLf & "Do you wish to continue?", MsgBoxStyle.YesNo, "Freeze Thread")

If MsgBoxAnswer = vbYes Then
btnClickMe.Enabled = True
Threading.Thread.Sleep(5000)
btnClickMe.Enabled = False
MsgBox("Thread is back and running!", vbInformation, "Back")
End If
End Sub
Private Sub btnClickMeWithoutMultithreading_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClickMe.Click
MsgBox("Wow, good job!", vbExclamation, "")
End Sub
#End Region

#Region "This is all the code used for Multithreading"
Dim threadFreeze As System.Threading.Thread
Dim WithEvents threadFreezeMe As cFreezeME

Private Sub btnClickMeWithMultithreading_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClick.Click
MsgBox("Meh, that was easy." & vbCrLf & "Thread status: " & threadFreeze.ThreadState.ToString, , "")
End Sub

Private Sub btnFreezeWithMultithreading_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFreezeWithMultithreading.Click
Dim MsgBoxAnswer As String = MsgBox("Freezing the thread will NOT make the application freeze for 5 seconds." & vbCrLf & "Do you wish to continue?", MsgBoxStyle.YesNo, "Freeze Thread")


Dim threadFreezeMe As New cFreezeME

threadFreeze = New Threading.Thread(AddressOf threadFreezeMe.FreezeME)

If MsgBoxAnswer = vbYes Then
btnClick.Enabled = True
threadFreeze.Start()
End If

End Sub
'Create a new class so we can do cross-class calls.
Public Class cFreezeME
Public Function FreezeME()
Threading.Thread.Sleep(5000)
Return MsgBox("Thread woke up!", vbInformation, "Ooh noes!")
End Function
End Class
#End Region


End Class
[/php]
Multithreading.rarattachment deleted · 6 downloads before removal
Also post the source in this topic.
nice, you will allways need multi threading
Very informative and simple to follow, thanks for that!
Neato.

Approved.
is multithreading taking advantage of multiple cores
EX: dual core, quad core or???
I know im gonna sound stupid here, but wth is multithreading
Quote Originally Posted by dudezone2 View Post
I know im gonna sound stupid here, but wth is multithreading
i just asked that.
Quote Originally Posted by mnpeepno2 View Post
i just asked that.
Let me google that for you

Also, on a side note, your photoshop skills are pretty poor with your edit in your signature . I highly doubt NextGen would have said that about any member, doesn't strike me as the type to bitch about people behind their backs /
Quote Originally Posted by Imported View Post


Let me google that for you

Also, on a side note, your photoshop skills are pretty poor with your edit in your signature . I highly doubt NextGen would have said that about any member, doesn't strike me as the type to bitch about people behind their backs /
1st of all, I only make GUI's from photoshop
2nd, this is the real image UNEDITED
3rd, you dont need to spam about it u could easily Vm'ed me
Quote Originally Posted by mnpeepno2 View Post
1st of all, I only make GUI's of photoshop
2nd, this is the real image UNEDITED
3rd, you dont need to spam about it u could easily Vm'ed me
He didn't spam about it rofl, he also answered your question about multi-threading, not everyone here spams you know . Also, NG denies that he ever wrote that so whatever buddy /... Who to believe, you or NextGen? What a real no-brainer.
Quote Originally Posted by Jason View Post


He didn't spam about it rofl, he also answered your question about multi-threading, not everyone here spams you know . Also, NG denies that he ever wrote that so whatever buddy /... Who to believe, you or NextGen? What a real no-brainer.
what do believe?

a real image, or something that someone could of said and edited.

And you can't prove to me that he didn't say that unless you have an actual proof

What would a jury say is the liar?/yea
Quote Originally Posted by mnpeepno2 View Post
what do believe?

a real image, or something that someone could of said and edited.

And you can't prove to me that he didn't say that unless you have an actual proof

What would a jury say is the liar?/yea
No, I'm not going to spam the VB section with another argument with you. If you have a problem with me, take it to VM/PMs and I'll be happy to flame the fuck out of you.

/request lolland remove all flame/spam posts <3
Closing because of spam.
Posts 1–14 of 14 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?