4 Replies - 259 Views - Last Post: 16 October 2017 - 11:15 PM Rate Topic: -----

#1 KC10513  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-October 17

Threadpool updating status column

Posted 16 October 2017 - 12:41 AM

Hi Everybody,

I am working on this project where i need to update a status column from a listview.
My listView has an IPv4 and Port number for each item and i have a Sync button that need to do all bunch of stuff like firstly connecting to remote device (When this happening i would like to show Connecting....), when connection is successful i want to to jump to another process which is sending data(While happening i want to show Sending data or writing data...) and finally if everything is successful i want to show(Success message).
due to factors outside of my control, I must use .NET 2.0, which prevents me using Task<T>, therefore i have to use threadpool.QueueUserworkItem to update any work being done.

Any help would be higly appreciate

This post has been edited by andrewsw: 16 October 2017 - 02:35 AM
Reason for edit:: removed VB.NET from topic title


Is This A Good Question/Topic? 0
  • +

Replies To: Threadpool updating status column

#2 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6380
  • View blog
  • Posts: 25,775
  • Joined: 12-December 12

Re: Threadpool updating status column

Posted 16 October 2017 - 02:36 AM

You've outlined what you need to achieve, which is good. Do you have a specific question to ask?
Was This Post Helpful? 0
  • +
  • -

#3 KC10513  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-October 17

Re: Threadpool updating status column

Posted 16 October 2017 - 03:10 AM

My question is how do i update my status column everytime a new process is started on my thread,

here's what i started:
Private Sub ConnectionToReader(ByVal BiometricDetails As PDConnect.clsBiometricReader)
        'IsConnected = BiometricFunction.ConnectReader()
        btnAdd.Enabled = False
        btnDelete.Enabled = False
        btnEdit.Enabled = False
        btnSync.Enabled = False
        For Each LvItem As ListViewItem In lvItems.Items
            IsConnected = BiometricFunction.ConnectReader("192.168.201.1", 4370) 
              'While this establishing the connection i would like to show (Connecting...) if successfully established
              'another process will start(sending or writing data...)
              'then finally a (successfull or failed message)
        Next
        btnAdd.Enabled = True
        btnDelete.Enabled = True
        btnEdit.Enabled = True
        btnSync.Enabled = True
    End Sub

 Private Sub Initialize(ByVal State As Object)

        'This is my Object.
        Dim MyObject As MyClassB = DirectCast(State, MyClassB )

        Invoke(New ConnectionToReaderWaitCallback(AddressOf ConnectionToReader), MyObject)
    End Sub

'This will be called on buttonSync_Click
 Private Sub Synchrinization()
        Dim MySynch As Threading.WaitCallback = New Threading.WaitCallback(AddressOf Initialize)

        For Each LvItem As ListViewItem In lvItems.Items
            Threading.ThreadPool.QueueUserWorkItem(MySynch, LvItem.Tag)
        Next

    End Sub


Was This Post Helpful? 0
  • +
  • -

#4 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1447
  • View blog
  • Posts: 3,682
  • Joined: 01-February 13

Re: Threadpool updating status column

Posted 16 October 2017 - 03:56 PM

What is a MyClassB, is it a PDConnect.clsBiometricReader? Is it a PDConnect.clsBiometricReader type that you have assigned to each of the ListViewItems Tag properties?

I ask this because, it is not making sense to me why you are passing the ListViewItem's Tag to the Initialize sub where you are casting it to a MyClassB type and then passing that MyClassB object to the ConnectionToReader sub which is expecting you to pass it a PDConnect.clsBiometricReader type.

Also, what is the ConnectionToReaderWaitCallback? Is it a special callback delegate that comes from the clsBiometric library, or is it a delegate that you have declared/created in your code somewhere?

Being that i do not have this clsBiometric library, i have no idea what it does or how it is suppose to be used. The answers to the questions i asked above will help me to better understand what you are trying to do with the code. Until then, i can't really suggest a which way to set it up.
Was This Post Helpful? 0
  • +
  • -

#5 KC10513  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-October 17

Re: Threadpool updating status column

Posted 16 October 2017 - 11:15 PM

i just dump all the code i was trying at that moment as am still doesnt have the right solution to this but to answer your questions PDConnect.clsBiometricReader is my class that contains multiple objects.
ConnectionToReaderWaitCallback is a delegate that i'v declare in my code just to reference the method ConnectionToReader (again i was just confuse :stuart: )
the code above is just some crap am trying i still haven't figure out the best answer to this.

i knw my code doesnt really make sense now but this was all part of trying whatever i had in mind.
if possible to have a good exemple of how i can achieve this, it will be great.

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1