Commandes multithreading obsolete

Résolu
Sentynel Messages postés 85 Date d'inscription jeudi 7 janvier 2010 Statut Membre Dernière intervention 13 juillet 2013 - 25 juil. 2011 à 17:32
Sentynel Messages postés 85 Date d'inscription jeudi 7 janvier 2010 Statut Membre Dernière intervention 13 juillet 2013 - 28 juil. 2011 à 21:09
Bonjour,
voulant faire un système multi-threading sur mon logiciel pour eviter que celui-ci "freeze" lors d'un acces à une base de données, Visual Studio m'affiche que cette commande est obsolete depuis .net framework 4.0.

les commandes sont thread.suspend et thread.resume

Est ce que quelqu'un pourrai m'aider svp ?

  Sub DownloadProcess()
        If My.Computer.FileSystem.FileExists(Application.StartupPath & "\TheAPP.exe") = True Then
            My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\TheAPP.exe")
        End If
        Thread2 = New System.Threading.Thread(AddressOf DownloadFiles)
        Thread2.Start()
        Thread.Suspend()
        If My.Computer.FileSystem.FileExists(Application.StartupPath & "" & Label1.Text) = True Then
            My.Computer.FileSystem.DeleteFile(Application.StartupPath & "" & Label1.Text)
        End If
        My.Computer.FileSystem.RenameFile("TheAPP.exe", Label1.Text)

        If CheckBox1.Checked = True Then
            Dim wsh As Object = CreateObject("WScript.Shell")
            Dim MyShortcut, DesktopPath
            wsh = CreateObject("WScript.Shell")
            DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            MyShortcut = wsh.CreateShortcut(DesktopPath & "\Savegame Manager 2 BETA.lnk")
            MyShortcut.TargetPath = wsh.ExpandEnvironmentStrings(Application.StartupPath & "" & System.IO.Path.GetFileName(Application.ExecutablePath))
            MyShortcut.WorkingDirectory = wsh.ExpandEnvironmentStrings(Application.StartupPath)
            MyShortcut.WindowStyle = 4
            MyShortcut.Save()
        End If
        Button2.Text = "Downloaded"
        Thread.Abort()
    End Sub

    Sub DownloadFiles()
        My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/24209719/Savegame%20Manager/SGMnewver.exe", Application.StartupPath & "\TheAPP.exe")
        Thread.Resume()
        Thread2.Abort()
    End Sub

2 réponses

Utilisateur anonyme
26 juil. 2011 à 18:41
Bonsoir,

Tu peux te servir entre autres de la classe Monitor :
Threading.Monitor.Enter(t)
'mise en attente
Threading.Monitor.Wait(t, System.Threading.Timeout.Infinite)
'et ca repart ;)
Threading.Monitor.Pulse(t)
Threading.Monitor.Exit(t)


Bonne soirée.
3
Sentynel Messages postés 85 Date d'inscription jeudi 7 janvier 2010 Statut Membre Dernière intervention 13 juillet 2013
28 juil. 2011 à 21:09
Merci de ton aide ! :)
0
Rejoignez-nous