Click here to Skip to main content
15,890,512 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Need help on VB.Net program communicting with website to retrieve data Pin
Eddy Vluggen3-Mar-10 2:22
professionalEddy Vluggen3-Mar-10 2:22 
GeneralRe: Need help on VB.Net program communicting with website to retrieve data Pin
orvries3-Mar-10 2:40
orvries3-Mar-10 2:40 
QuestionVB Codes Pin
faizalfz2-Mar-10 19:37
faizalfz2-Mar-10 19:37 
AnswerRe: VB Codes Pin
Richard MacCutchan2-Mar-10 21:29
mveRichard MacCutchan2-Mar-10 21:29 
QuestionPop up Notification Design Pin
structures832-Mar-10 12:04
structures832-Mar-10 12:04 
AnswerRe: Pop up Notification Design Pin
Wayne Gaylard2-Mar-10 14:07
professionalWayne Gaylard2-Mar-10 14:07 
AnswerRe: Pop up Notification Design Pin
The Man from U.N.C.L.E.2-Mar-10 22:42
The Man from U.N.C.L.E.2-Mar-10 22:42 
QuestionThread slow down system Pin
Gagan.201-Mar-10 23:36
Gagan.201-Mar-10 23:36 
Hi all...

I am creating a project to monitor files of USB disk each time when it is inserted.
When a USB disk is inserted, a thread starts and checks all executable files in usb disk. when user run any executable in usb disk then thread immediately stops its execution. The code is working properly but it slow down the system.

The code is below :

 Private Sub StartMonitoring()
        Dim MonitorList As New List(Of String)

        For Each drive As DriveInfo In System.IO.DriveInfo.GetDrives
        If drive.DriveType = DriveType.Removable And drive.Name <> "A:\" Then
        DriveName = drive
        End If
        Next

For Each file As String In My.Computer.FileSystem.GetFiles(DriveName.Name,FileIO.SearchOption.SearchAllSubDirectories)
        If IO.Path.GetExtension(File) = ".exe" Then
        MonitorList.Add(File)
        End If
        Next
        
        Do While Not memThd Is Nothing 'memThd is thread which is started to monitor.
            Try

            For Each prcName As String In MonitorList
            For Each prc As Process In Process.GetProcesses
            If IO.Path.GetFileName(prcName) = prc.ProcessName & ".exe" Then
            prc.Kill()

            catch ex as exception
            msgbox(ex.message)
             End Try
        Loop
    End Sub


The code is working perfectly but it slow down the system.
Suggest me some way to maintain system speed while running this thread or some other way to write the above code.

Thanks

Gagan
AnswerRe: Thread slow down system Pin
Paulo Zemek2-Mar-10 1:54
mvaPaulo Zemek2-Mar-10 1:54 
GeneralRe: Thread slow down system Pin
Gagan.204-Mar-10 3:59
Gagan.204-Mar-10 3:59 
AnswerRe: Thread slow down system Pin
Dave Kreskowiak2-Mar-10 1:56
mveDave Kreskowiak2-Mar-10 1:56 
GeneralRe: Thread slow down system Pin
Gagan.204-Mar-10 4:04
Gagan.204-Mar-10 4:04 
GeneralRe: Thread slow down system Pin
Dave Kreskowiak4-Mar-10 12:57
mveDave Kreskowiak4-Mar-10 12:57 
Questioncould not find a part of the path... [modified] Pin
mehrnoosh1-Mar-10 21:01
mehrnoosh1-Mar-10 21:01 
AnswerRe: could not find a part of the path... Pin
εїзεїзεїз2-Mar-10 1:40
εїзεїзεїз2-Mar-10 1:40 
GeneralRe: could not find a part of the path... Pin
mehrnoosh5-Mar-10 18:30
mehrnoosh5-Mar-10 18:30 
QuestionHow do you consume an existing web serivce Pin
gengel1-Mar-10 20:14
gengel1-Mar-10 20:14 
AnswerRe: How do you consume an existing web serivce Pin
Steven J Jowett2-Mar-10 0:38
Steven J Jowett2-Mar-10 0:38 
GeneralRe: How do you consume an existing web serivce Pin
gengel2-Mar-10 1:12
gengel2-Mar-10 1:12 
QuestionAdding a signature to vb.net form Pin
fresh12071-Mar-10 15:52
fresh12071-Mar-10 15:52 
AnswerRe: Adding a signature to vb.net form Pin
EliottA1-Mar-10 16:45
EliottA1-Mar-10 16:45 
GeneralRe: Adding a signature to vb.net form Pin
fresh12072-Mar-10 12:32
fresh12072-Mar-10 12:32 
GeneralRe: Adding a signature to vb.net form Pin
Dave Kreskowiak2-Mar-10 12:40
mveDave Kreskowiak2-Mar-10 12:40 
GeneralRe: Adding a signature to vb.net form Pin
fresh12072-Mar-10 16:13
fresh12072-Mar-10 16:13 
GeneralRe: Adding a signature to vb.net form Pin
Dave Kreskowiak2-Mar-10 18:45
mveDave Kreskowiak2-Mar-10 18:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.