.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

Multi Threading in Visual Basic.Net

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh




'Sample Code on how to use multithreading in Visual Basic .Net

Imports System
Imports System.Threading
Public Module ThreadSample
Public Balance As Integer = 1000
Sub Main()
Dim account As Account = New Account()
Dim depositeBalance1 As DepositeBalance = New _
DepositeBalance(account, 1000, "Customer 1")
Dim depositeBalance2 As DepositeBalance = New _
DepositeBalance(account, 1000, "Customer 2")
Dim t1 As Thread = New _
Thread(AddressOf depositeBalance1.DepositeAmount)
Dim t2 As Thread = New _
Thread(AddressOf depositeBalance2.DepositeAmount)
t1.Start()
t2.Start()
Try
t1.Join()
t2.Join()
Catch e As Exception
Console.Write(e.ToString())
Finally
'Do Nothing
End Try
End Sub
Public Class Account
Private balanceAmount As Integer
Public Sub Deposite(ByVal amount As Integer, _
ByVal message As String)
Console.Write(message & _
" Depositing Amount " & amount)
Console.Write(message & " Checking Previous Balance")
Monitor.Enter(Me)
balanceAmount = getBalance()
Console.Write(message & _
" Previous Balance in Account " & balanceAmount)
balanceAmount += amount
Console.Write(message & _
" Updating Balance in Account ")
setBalance(balanceAmount)
Monitor.Exit(Me)
Console.Write(message & " Update Balance " & Balance)

End Sub
Private Function getBalance() As Integer
Try
Thread.sleep(1000)
Catch e As Exception
Console.Write(e.ToString())
Finally
'Do Nothing
End Try
Return Balance
End Function

Private Sub setBalance(ByVal amount As Integer)
Try
Thread.sleep(1000)
Catch e As Exception
Console.Write(e.ToString())
Finally
'Do Nothing
End Try
Balance = amount
End Sub
End Class

Public Class DepositeBalance
Private account As Account
Private amount As Integer
Private message As String

Public Sub new(ByRef account As Account, _
ByVal amount As Integer, ByVal message As String)
MyBase.New()
Me.account = account
Me.amount = amount
Me.message = message
End Sub
Public Sub DepositeAmount()
Account.Deposite(amount, message)
End Sub
End Class
End Module

Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel Multi Threading in Visual Basic.Net, Diterbitkan oleh scodeaplikasi pada Selasa, 27 April 2010. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to