تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تكرار أوامر برمجية معينة علي فترات زمنية متباعدة
#1
افتح مشروع
ضع به الكود التالي
ستلاحظ ان MessageBox ستظهر لك اكثر من مرة

الفكرة الهدف منها توضيح كيفية تكرار أمر برمجي معين باستخدام Threading و هذه الفكرة يمكن استخدامها في صور كثيرة
الأمر متروك لمخيلتكم


PHP كود :
Public Class Form1
    Private Sub Form1_Load
(sender As ObjectAs EventArgsHandles 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((1), (interval), interval))
 
           End Try
 
       Next

    End Sub

    Private Sub DoAnyAction
()
 
       MessageBox.Show("msg box will repeated 5 times""info")
 
   End Sub
End 
Class 
الرد }}}
تم الشكر بواسطة: السندبااد


الردود في هذا الموضوع
تكرار أوامر برمجية معينة علي فترات زمنية متباعدة - بواسطة silverlight - 23-12-16, 04:45 PM


التنقل السريع :


يقوم بقرائة الموضوع: