|
-
Oct 11th, 2003, 03:40 PM
#1
Thread Starter
Addicted Member
threading, Q2?!
I have a listview in my program, am i going to have any problems if 2diff thread access ( read and write ) to it at the same time?!
if yes what to do? ( can we syncronize it somehow? )
and another question that has to do with threading in genral , when 2 threads access the same obj, are we only gonna have problems when they both want to write to it? or problems happen both when writting and reading?
thanks for your times again...
-
Oct 11th, 2003, 05:36 PM
#2
Frenzied Member
Re: threading, Q2?!
Originally posted by persianboy
I have a listview in my program, am i going to have any problems if 2diff thread access ( read and write ) to it at the same time?!
if yes what to do? ( can we syncronize it somehow? )
and another question that has to do with threading in genral , when 2 threads access the same obj, are we only gonna have problems when they both want to write to it? or problems happen both when writting and reading?
thanks for your times again...
Yes you will have problems. You have to lock the thread while you write. Use the synclock keyword.
-
Oct 12th, 2003, 01:08 AM
#3
Thread Starter
Addicted Member
which thread? is there anyway to synlock the listview?!
-
Oct 12th, 2003, 01:35 AM
#4
Whatever method access and uses the Listview should use a SyncLock block around the listview usage. Also remember that you can't create a UI object in an alternate thread and add it back into the main thread. In other words you can create a New ListViewItem in a thread other than the UI thread (main thread). There are some exceptions like using Invoke, but generally speaking.
-
Oct 12th, 2003, 02:27 AM
#5
Thread Starter
Addicted Member
the listview is in the main thread. the question do i have to synclock the listview object, or the methods that try to access it?
can you write the one line that synclock the control for me, thanks
-
Oct 12th, 2003, 03:22 AM
#6
Synclock doesn't work like that. It takes at least three lines at least to use it. Read the help on it.
VB Code:
SyncLock listview1
'put any code to add or whetver to the listview here
End SyncLock
-
Oct 12th, 2003, 03:28 AM
#7
Thread Starter
Addicted Member
i changed it, thanks.
and the question thats on the first msg of this thread still remains unanswered to me >>
when 2 threads access the same obj, are we only gonna have problems when they both want to write to it? or problems happen both when writting and reading?
-
Oct 12th, 2003, 03:29 AM
#8
Re: Re: threading, Q2?!
Originally posted by DevGrp
Yes you will have problems. You have to lock the thread while you write. Use the synclock keyword.
Yes and that should be on reading and writing, anytime they try to access the same object at the same time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|