Re: display message in work thread

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Mihajlo,

I think this is turning into one of the "religious" discussions :o) There are obviously lots of ways to do things. I think you'll find that the general consensus is that popping up messages from worker threads can lead to some trouble, but it probably works most of the time if you really want to do it. I have a specific problem where I have an API that I use that creates it's own thread then does a callback into my thread (not my favorite paradigm). Anyway, when it calls back it technically is coming from a different process so if I try to pop up a dialog box using a resource (like a string) since I would never put in a static string, it either asserts if there is no string resource with the same number, or it displays the string it happens to find which is probably wrong.

It took me a while to debug through this problem once and because of that I always use the send message method (to the UI thread) whenever I need to display or use any resource. Of course, my situation was pretty specific.

Tom

"Mihajlo Cvetanovic" <mcvetanovic@xxxxxxxxxxxxxxxxxxx> wrote in message news:e9Uv0RsIIHA.588@xxxxxxxxxxxxxxxxxxxxxxx
Joseph M. Newcomer wrote:
Because I would never consider a thread that required user interaction to be a
well-designed thread. Worker threads do not interact with users.

It seems to me that David and you made generalized conclusions based on some specific situation. I agree that worker threads should do the work, but if they can't (do the work) and must wait on user then there's no reason to interact with user through some other thread. The only issue I see right now is how to finish the thread if it has message box open (from Tom's post). It may be a good idea to have a custom made message box to handle this.

Creating windows in different threads is probably a bad idea in general case, but I believe that there are cases where window in worker thread works just fine without unwanted side effects.

.



Relevant Pages

  • Re: Other version information
    ... header to locate the resource table. ... Windows PE files ... marked by a literal string. ... files in a folder, ...
    (microsoft.public.scripting.vbscript)
  • Re: Culture-specific file size units ("KB" vs. "Koctets") ?
    ... I don't know of a function to retrieve the information from Windows. ... However you could set up a "string table" resource that you then localize. ...
    (microsoft.public.dotnet.general)
  • Re: Automating VB IDE ?
    ... Would it be possible to open the RES file in binary mode and replace ... could extract the resource in any Windows version. ... to get it to work to no avail, just to change a simple string. ... a new resource and not replacing the string already stored. ...
    (microsoft.public.vb.general.discussion)
  • how to copy resource from VC6 project to EVC project?
    ... Hello,I am developing a software run on both windows xp and windows ce. ... The second problem is that the string in combbox's data field become ... The last problem is that some time the resource ID become a number .For ...
    (microsoft.public.windowsce.embedded.vc)
  • [API] Win32 Resources - List Icon Resource Names
    ... private static extern IntPtr LoadLibraryEx(string FileName, ... /// Gets the string resource names for the current file. ...
    (microsoft.public.dotnet.languages.csharp)