23-12-16, 04:45 PM
(آخر تعديل لهذه المشاركة : 23-12-16, 04:46 PM {2} بواسطة silverlight.)
افتح مشروع
ضع به الكود التالي
ستلاحظ ان MessageBox ستظهر لك اكثر من مرة
الفكرة الهدف منها توضيح كيفية تكرار أمر برمجي معين باستخدام Threading و هذه الفكرة يمكن استخدامها في صور كثيرة
الأمر متروك لمخيلتكم
ضع به الكود التالي
ستلاحظ ان MessageBox ستظهر لك اكثر من مرة
الفكرة الهدف منها توضيح كيفية تكرار أمر برمجي معين باستخدام Threading و هذه الفكرة يمكن استخدامها في صور كثيرة
الأمر متروك لمخيلتكم
PHP كود :
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' define repeat times
Dim trials As Integer = 5
' define repeat interval
Dim interval As Integer = 500
' loop
For i As Integer = 1 To trials
Try
' write the actin to be repeated
DoAnyAction()
Exit Try
Catch ex As Exception
' conditions
If i = trials OrElse Not TypeOf ex Is InvalidOperationException Then
Throw
End If
' sleep a period befor to try to do the action again
Threading.Thread.Sleep(If((i > 1), (2 * interval), interval))
End Try
Next
End Sub
Private Sub DoAnyAction()
MessageBox.Show("msg box will repeated 5 times", "info")
End Sub
End Class