Diminuer la ressource mémoire du CPU pour une tâche

Marko007 Messages postés 96 Date d'inscription mardi 15 mai 2007 Statut Membre Dernière intervention 29 janvier 2009 - 9 oct. 2008 à 09:22
Marko007 Messages postés 96 Date d'inscription mardi 15 mai 2007 Statut Membre Dernière intervention 29 janvier 2009 - 9 oct. 2008 à 12:02
Bonjour,

comment est-il possible de diminuer au niveau du processeur (l'occupation en taille mémoire) ?

>> Options dans Visual Studio 2005, objet vb à ne pas utiliser, code source à améliorer,...

J'ai une tâche qui prend +/- 50 Mb en ressource mémoire lorsqu'elle tourne (>> Task manager de Windows XP) :

---------------------------------------------------------
Public Class FrmMain
    Dim StrPing As String
    Dim StrTime As String
    Dim StrShell As String
    Dim iFaultPing As Integer

    Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim IntStrPing As Integer
        Dim IntStrTime As Integer
        Dim IntStrShell As Integer

        StrPing = ""
        StrTime = ""
        StrShell = ""
        IntStrPing = 0
        IntStrTime = 0
        IntStrShell = 0

        FileOpen(1, My.Application.Info.DirectoryPath & "\Pingparam.ini", OpenMode.Input)

        StrPing = LineInput(1)
        StrTime = LineInput(1)
        StrShell = LineInput(1)

        FileClose(1)

        IntStrPing = InStr(StrPing, "'", CompareMethod.Text)
        If IntStrPing <> 0 Then StrPing = Trim(Mid(StrPing, 1, IntStrPing - 1))

        IntStrTime = InStr(StrTime, "'", CompareMethod.Text)
        If IntStrTime <> 0 Then StrTime = Trim(Mid(StrTime, 1, IntStrTime - 1))

        IntStrShell = InStr(StrShell, "'", CompareMethod.Text)
        If IntStrShell <> 0 Then StrPing = Trim(Mid(StrShell, 1, IntStrShell - 1))

        LblIP.Text = LblIP.Text & " : " & StrPing
        LblTimePing.Text = LblTimePing.Text & " : " & StrTime
        LblShell.Text = LblShell.Text & " : " & StrShell
        TmrPing.Interval = Val(StrTime) * 1000

    End Sub

    Private Sub TmrPing_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TmrPing.Tick
        Dim shel1, shel2 As Object
        Dim sCmd1, sCmd2 As String
        Dim returnShel1 As Integer

       
        shel1 = CreateObject("wscript.shell")
        shel2 = CreateObject("wscript.shell")

        sCmd1 = "ping " & StrPing
        returnShel1 = shel1.run(sCmd1, 0, True)

        If returnShel1 = 1 Then
            iFaultPing = iFaultPing + 1
            TmrPing.Interval = 25000
        End If

        If iFaultPing > 3 Then
            sCmd2 = StrShell
            shel2.run(sCmd2)
            iFaultPing = 0
            TmrPing.Interval = Val(StrTime) * 1000
            End
        End If

        LblFault.Text = iFaultPing
        LblTimer.Text = TmrPing.Interval

    End Sub
End Class

---------------------------------------------------------

Merci,
Marco

2 réponses

gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 2
9 oct. 2008 à 10:45
fileopen , lineinput , wscript.shell"   

a virer absolument si tu veux fairte du .net utilise le framework

class io.streamwriter   à la pace de fileopen  et lineinput
ou
my.computer.filesystem

pour faire un ping il y a plusieurs façons .
si tu tiens à utiliser la commande ping du systeme
utilise la classe process à la place de wscript.shell

 

sinon

My.Computer.Network.Ping  
ouSystem.Net.NetworkInformation.Ping

Bonjour chez vous !
0
Marko007 Messages postés 96 Date d'inscription mardi 15 mai 2007 Statut Membre Dernière intervention 29 janvier 2009
9 oct. 2008 à 12:02
Ok,

comment puis-je faire pour envoyer une commande PING à partir d'une carte réseau déterminée.
Et vérifier que le PING a été Ok ?

Marco
0
Rejoignez-nous