Re: Thread day for Scott Martin



About the only DB threading I use in my database applications is a Progress dialog that I wrote which takes a pointer to an event. The progress dialog creates a worker thread and executes the event. The event must be thread friendly (no UI other than through either through the ProgressDialog class passed to it on Synchronize).

The reason I use the progress dialog is that it:

1) Allows my program to redraw itself if the user switches to another program - I am amazed at how many programmers just put up an hourglass cursor.

2) It gives the user an indication that the program isn't locked up if the operation is long (like a report generation).

3) It allows the user to abort the operation if necessary.

4) The dialog can catch exceptions from the worker thread and pass it along.

I do use threads in my database applications for other things like monitoring for email messages, etc.

Best Regards,

Shane
.



Relevant Pages

  • Re: 2 different threads checking on same variable scenario
    ... Because you are implementing a console application here, it seems to me that a third way to implement this would be to simply have the main thread call some "do work" function repeatedly. ... Depending on just what you intended to do in your "do progress indicator thing" loop, there may be a fourth option. ... That is, use an auto-reset wait event to block the main thread between progress updates, a flag to indicate when the work has been done, and then have the worker thread set the flag when it's done, and intermittently set the wait event to indicate to the main thread to update the progress. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: 2 different threads checking on same variable scenario
    ... it depends on what you intend to do in your main thread's loop. ... Depending on just what you intended to do in your "do progress indicator ... indicate when the work has been done, and then have the worker thread set ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: BN_CLICKED Event Handler in Background
    ... Using Sleep in the worker thread is very clumsy because then you don't have any way to make the thread shut down when the program is closing. ... Have the thread post user-defined messages to the main window, reporting whatever progress you like in wParam/lParam. ... The main window message handler keeps track of the progress and displays whatever you like. ...
    (microsoft.public.vc.mfc)
  • Re: MessageBox?
    ... don't use 'SendMessage'; SendMessage does not return until the ... >> actual show/hide/update of the progress bar and let the worker thread ... >> it about progress by means of PostMessage. ... >> potentially leak resources... ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: MessageBox?
    ... don't use 'SendMessage'; SendMessage does not return until the ... >> actual show/hide/update of the progress bar and let the worker thread ... >> it about progress by means of PostMessage. ... >> potentially leak resources... ...
    (microsoft.public.pocketpc.developer)