
This is a copy of the Visual Studio 97 Service Pack 3 Readme (English language version). For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe. Before you edit the registry, make sure you understand how to restore it if a problem occurs. IMPORTANT: This article contains information about editing the registry.
Microsoft Visual Studio 97 Service Pack 3. The information in this article applies to: INFO: Visual Studio 97 Service Pack 3 Readme 1 INFO: Visual Studio 97 Service Pack 3 Readme. In fact, it's actually a dangerous thing to do - if you decided to wait for the background thread to finish, you'd end up with a deadlock, and your application would hang indefinitely.
Hopefully you can see from that description that there is absolutely no benefit in starting a new thread to call CreateResultsListItem.
The first call to CreateResultsListItem running on the background thread is notified that the second call has completed, and the new thread ends. CreateResultsListItem then runs a second time on the UI thread, blocking the UI until it has finished. CreateResultsListItem finds that it's not running on the UI thread, and marshals the call back to the UI thread. On the UI thread, startButton_Click starts a new thread to call the CreateResultsListItem method. Which is why the first thing your CreateResultsListItem does is check whether it's running on a non-UI thread, and if so, invoke the method on the UI thread instead.īut that means your code does the following: Var threadParameters = new ThreadStart( delegate įoreach ( String filename in Searcher.Info_Kword)įoreach ( String file in Searcher.Info_Fnames)Īs you've discovered, you cannot access UI controls from a non-UI thread. If the function runs, it returns a true boolean in this case. The Start function is to run the thread in another class, Searcher class. Private void startButton_Click( object sender, EventArgs e)