CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2001
    Location
    Israel
    Posts
    94

    Call Back function problem

    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


  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Call Back function problem

    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.


  3. #3
    Join Date
    Feb 2001
    Location
    Israel
    Posts
    94

    Re: Call Back function problem

    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


  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Call Back function problem

    *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
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Feb 2001
    Location
    Israel
    Posts
    94

    Re: Call Back function problem

    My VB crushes every second minute
    I cannot work that way...
    Whats the ****ing problem?

    FatMan


  6. #6
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Call Back function problem

    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
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured