CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2000
    Location
    CA, USA
    Posts
    88

    Threads, how safe are they to use in VB5?

    Hello,

    I have a form that displays a progress bar to show the progress an the current operation. On the form is a timer that is suppose to update the progress bar based upon the start time, current time and the average overall time to complete the process. Within the timer it call certain function that are created using VC++. The problem is that the progress bar isn't updating in real time. It appears that when the a call is made to the VC DLL that it pauses operation of the timer. This makes sense since VB is a single threaded application ( at least from what I understand ). So my options ( from my limited expousre to VB ) are

    1) Get the VC++ developers to create a thread and spin off the process. This way it gives back control to the VB code. This is the best solution I feel, but since this portion of the code is froze there is no way I will be able to implement this solution.

    2) Is create a seperate thread that only deals with update this progress bar, but from what I have read threads are not that safe in VB.

    3) Maybe subclass the WinProc and use this to update the progress bar in some fashion.

    I figure my best solution, currently, is to implement a thread, but I need real good reliablity for this apllication. Does anyone have any other suggestions?

    Mark


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Threads, how safe are they to use in VB5?

    I feel multithreading is somehow not stable in VB, however, if u would like to implement it, point ur browser to http://vblib.virtualave.net and download the DLL, there is a class vbMultiThreading which might help, come with example as well.

    HTH


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

    Re: Threads, how safe are they to use in VB5?

    The way that I have handled a similar situation is to have the VB pass a function pointer to an UpdateStatus function that the C dll calls after each iteration. The VB program and C dll are in the same thread and use callbacks so the application is more stable than would be the case with threads.

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  4. #4
    Join Date
    Jul 2000
    Location
    CA, USA
    Posts
    88

    Re: Threads, how safe are they to use in VB5?

    This is a nice idea, but unfortunately the C code has been frozen and they is no way I will be able to push this small fix through. They will just have to live with the current implementation I guess until next release.

    Mark


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