تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مشروع مفتوح المصدر لنسخ الملفات او عمل نسخة احتياطية بتعدد المسارات
#1
استخدام Multithreading في نسخ الملفات

حيث احدى العمليات تقوم بالنسخ والاخرى تظهر اسم الملفات التي يتم نسخها وعملية اخرى تحسب الوقت المتبقى
ملف المشروع بالمرفقات



وهنا نظرة سريعة على المشروع

PHP كود :
Imports System.Threading
Imports System
.IO
Imports System
.Diagnostics.Process 


PHP كود :
Imports System.Windows

Public Class Backup

    
' Declare the FileCopy class.
    ' 
This class will create 3 threads to copycount and mirror files
    
' and raise events for each, so the events must be handled
    ' 
to update the form with status data.
 
   Dim WithEvents CopyFiles As FileCopy

    Private Sub StartCopy_Click
(ByVal sender As System.ObjectAs System.EventArgs_
        Handles StartCopy
.Click

        
' Create the FileCopy class which will initiate the threads
        CopyFiles = New FileCopy

        ' 
Initiate the copycount and mirror threads from the FileCopy class
 
       CopyFiles.StartCopy()

 
   End Sub
    
.
 
   remaining forms code
    
.
End Class 


PHP كود :
Imports System.IO

Public Class FileCopy

    
' Declares the variables you will use to hold your thread objects.
    Public CopyThread As System.Threading.Thread
    Public CountThread As System.Threading.Thread
    Public MirrorThread As System.Threading.Thread

    Public Sub StartCopy()

        ' 
Sets the copy and count threads using the AddressOf the subroutine where
        
' the thread will start.
        CopyThread = New System.Threading.Thread(AddressOf Copy)
        CopyThread.IsBackground = True
        CopyThread.Name = "Copy"
        CopyThread.Start()

        CountThread = New System.Threading.Thread(AddressOf Count)
        CountThread.IsBackground = True
        CountThread.Name = "Count"
        CountThread.Start()

    End Sub
    .
    . code for the rest of the class
    .
End Class 


PHP كود :
Imports System.IO

Public Class FileCopy

    
' Declare the events that will be raised by each thread
    Public Event CopyStatus(ByVal sender As Object, ByVal e As BackupEventArgs)
    Public Event CountStatus(ByVal sender As Object, ByVal e As BackupEventArgs)
    Public Event MirrorStatus(ByVal sender As Object, ByVal e As BackupEventArgs)

    ' 
Declares the variables you will use to hold your thread objects.
 
   Public CopyThread As System.Threading.Thread
    Public CountThread 
As System.Threading.Thread
    Public MirrorThread 
As System.Threading.Thread

    
' Class variables' Class variables
    Private _filePath 
As String
    Private _fileSize 
As String
    Private _copiedFolders 
As Long
    Private _copiedFiles 
As Long
    Private _countedFolders 
As Long
    Private _countedFiles 
As Long
    Private _mirroredFolders 
As Long
    Private _mirroredFiles 
As Long
    
.
 
   even more class variables but we will just show the relevant ones.
 
   .

 
   Public Sub StartCopy()

 
       ' Sets the copy and count threads using the AddressOf the subroutine where
        ' 
the thread will start.
 
       CopyThread = New System.Threading.Thread(AddressOf Copy)
 
       CopyThread.IsBackground True
        CopyThread
.Name "Copy"
 
       CopyThread.Start()

 
       CountThread = New System.Threading.Thread(AddressOf Count)
 
       CountThread.IsBackground True
        CountThread
.Name "Count"
 
       CountThread.Start()

 
   End Sub

     
Private Sub Copy()
 
       .
 
       this is a program loop with logic to copy files
        
.
 
       Loop to Copy Files

            Copy a file here

            
' Raise the copy status event at the end of the program loop
            RaiseEvent CopyStatus(Me, New BackupEventArgs_
                    ("", 0, _copiedFiles, _copiedFolders))
            Threading.Thread.Sleep(1)
        End Loop

      End Sub

      Private Sub Count()
        .
        . this is a program loop with logic to count files
        .
        Loop to Count Files

            Count a file here

            ' 
Raise the count status event at the end of the program loop
            RaiseEvent CountStatus
(Me, New BackupEventArgs_
                    
(""0_countedFiles_countedFolders))
 
           Threading.Thread.Sleep(1)
 
       End Loop

    End Sub
    
.
 
   code for the rest of the class
 
   .
End Class 


الملفات المرفقة
.zip   Backup.zip (الحجم : 254.66 ك ب / التحميلات : 354)
الرد }}}
تم الشكر بواسطة: sendbad100 , عبدالله الدوسري , asemshahen5
#2
جزاك الله خيرا وبارك فيك أخي الفاضل
لا إله إلا الله وحده لا شريك له له الملك وله الحمد وهو على كل شئ قدير
سبحان الله وبحمده سبحان الله العظيم
سبحان الله والحمد لله ولا إله إلا الله والله أكبر ولا حول ولا قوة إلا بالله العلى العظيم
رب أغفر لي 

الرد }}}
تم الشكر بواسطة: viv , viv


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [مثال] برنامج فتح الملفات من الأقراص Kamil 0 310 04-05-25, 10:10 PM
آخر رد: Kamil
  فكرة جميلة جدا : أزي تعمل عداد لعمر البرنامج بدون قاعدة بيانات(نسخة تجريبية) ggtt17121985 0 585 14-02-25, 02:55 AM
آخر رد: ggtt17121985
  [VB.NET] اعادة رفع نظام إدارة المدارس مفتوح المصدر الكاتب 46 43,600 08-02-25, 07:13 PM
آخر رد: الورد2
  [مشروع] مشروع إدارة الأقساط قابل للتعديل musalem 7 2,116 07-02-25, 08:09 PM
آخر رد: الورد2
  [VB.NET] مشروع لارسال اشعارات مثل push notifications للهواتف ميدو الفنان 1 839 30-01-25, 12:42 AM
آخر رد: Mina Botros
  [مشروع] مشروع ادارة المراكز الطبية رضوان الجماعي 9 4,714 05-11-24, 03:48 PM
آخر رد: hum100
  [مشروع] تطبيق ويب رائع لتحميل و رفع الملفات Necro 0 366 15-10-24, 05:19 PM
آخر رد: Necro
  [مشروع] تطبيق ويب رائع لتحميل و رفع الملفات 0 154 15-10-24, 05:17 PM
آخر رد: Necro
  [مشروع] تطبيق ويب رائع لتحميل و رفع الملفات 0 139 15-10-24, 05:11 PM
آخر رد: Necro
Wink [مشروع] مشروع انشاء برنامج يقوم بالتقاط اللون من اسفل المؤشر وتحويلة للهكس كود وار جي بي ahmadpal 2 1,749 01-10-24, 05:33 PM
آخر رد: مصمم هاوي

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


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