Click to See Complete Forum and Search --> : Call Back function problem
Lev FatMan
March 19th, 2001, 11:35 AM
Hello ,
I made this dll that call to a vb function that clears a listbox and then prints something to it.
I call it synchroniclly from the dll. Meaning there might be a case where two threads enter at the same time to it.
after I made a simple check of calling to the dll 10 times (meaning it called to the vb function 10 times) I recieved a long list of strings when I actually had to recieve some strings each time and then cleared and more strings...
How can I fix this problem???
FatMan
sotoasty
March 19th, 2001, 03:06 PM
I am not sure if I understand the question corretly but let me give it a shot. If I understand you correctly, you list box is getting filled with all ten messages at once, and you want it to be displyed 1 at a time? If I have this right you could try a few things.
1. In your callback function, clear the list. This way whenever a new string comes in, the list gets cleared.
2. In the Callback Function, Store the strings in an array and keep a counter. That way you can process them WHEN You want to. Not when the callbcak function gets called. For example, you could have a button or timer call a function that retrieves the next string in the array and display it.
Hope this helps.
Lev FatMan
March 20th, 2001, 10:42 AM
I am clearing the list before entering the new string, the strange thing is that it does not clear it.
I will try to call to a function that clears the list just before entering any new objects to it, but wont it make some problems if while I am entering some strings another thread is clearing the listbox?
FatMan
Clearcode
March 20th, 2001, 11:07 AM
*goes out on a limb*
I may be mistaken, but I remember reading that all VB intrinsic controls are thread safe - that is to say they have some sort of critical section around the code that updates the control content such that one thread cannot update the value whilst another is doing so.
If not you will need to implement a critical region using CreateMutex() - hopefullyu there is code available here ('cos I've never done it myself).
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Lev FatMan
March 20th, 2001, 11:54 AM
My VB crushes every second minute
I cannot work that way...
Whats the ****ing problem?
FatMan
Clearcode
March 20th, 2001, 12:00 PM
That is not to be expected, even having multiple threads accessing the same DLL.
I'd suggest you may have a configuration problem - try the Microsoft customer support? There are recent patches for Visual basic and Visual Studio that you might need.
It is very unlikely that this is due to your VB code so this site won't be able to help.
D.
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.