troubleshooting Question

What code will run my function in multiple threads?

Avatar of linuxrox
linuxroxFlag for United States of America asked on
Visual Basic.NET.NET Programming
1 Comment1 Solution88 ViewsLast Modified:
Hello.  I have written a function here in VB.NET that basically remotely connects to a computer and checks on the percent bitlocker complete status on the machine which takes a long time encrypting a boot drive of course.  i'm having to encrypt many machines and wrote this to let me know the status of each one.  Can anyone add the code here that will basically let me pass a list of computer names to my function and have it run in separate threads?  one per name...the list of computer names can be in an array or i  may just put them in a listbox or something...not sure on that yet

Here is the function and i currently call it as: show_progress("211mt03", 15, 15)  ....("computername", x,y)  x and y are the positions of the progress bar which i haven't figured that out yet actually.

Private Function show_progress(ByVal cname As String, ByVal x As Integer, ByVal y As Integer)
        Dim p1 As New ProgressBar
        Dim myConnectionOptions As New System.Management.ConnectionOptions
        With myConnectionOptions
            .Authentication = System.Management.AuthenticationLevel.Connect
            .Authentication = System.Management.AuthenticationLevel.PacketPrivacy
        End With
        Dim strComputer = cname
        Dim colItems As ManagementScope
        colItems = New ManagementScope("\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption", myConnectionOptions)
        If colItems.IsConnected = False Then
            MsgBox("Could not connect to WMI namespace")
        End If
        Dim query As ObjectQuery
        query = New ObjectQuery( _
            "SELECT * FROM Win32_EncryptableVolume")
        Dim searcher As ManagementObjectSearcher
        searcher = _
            New ManagementObjectSearcher(colItems, query)
        Dim queryCollection As ManagementObjectCollection
        queryCollection = searcher.Get()
        Dim m As ManagementObject
        For Each m In queryCollection
            Dim ConversionStatus As ManagementBaseObject = m.InvokeMethod("GetConversionStatus", Nothing, Nothing)
            Label1.Text = ConversionStatus("EncryptionPercentage").ToString & "%"
            '  ProgressBar1.Value = ConversionStatus("EncryptionPercentage")
            p1.Size = New Size(242, 24)
            p1.Location = New Point(x, y)
            p1.Value = ConversionStatus("EncryptionPercentage")
            p1.Visible = True
    End Function

Open in new window

Eric Greene
Director of Technology

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 1 Comment.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 1 Comment.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004