473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Disposing an object in another thread... how?

Hi,

I'm trying to close and dispose a form that is running in another
process, but I get the error message "A first chance exception of type
'System.ObjectDisposedException' occurred in system.windows.forms.dll",
"Additional information: Cannot access a disposed object named
"frmProgressWindow".".

Here's what I'm trying to do basically...

My main UI thread launches another thread in which I show a modal
Progress Window (form with a progress bar). When I'm done performing
certain actions, I want to close the progress window from my main
thread, so I call this code:

Private Sub CloseProgressWindow()
If _progressWindow Is Nothing Then Return
_progressWindow.Invoke(New CloseProgressWindowDelegate(AddressOf
_progressWindow.Close))
_progressWindow.Invoke(New DisposeProgressWindowDelegate(AddressOf
_progressWindow.Dispose))
End Sub

The exception occurs on the "End Sub" (!) line. See the screenshot at
http://www2.adonis.ca/disposeerror.png.

What am I doing wrong?

Thanks!

Carl
Nov 22 '05 #1
0 1293

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carl Mercier | last post by:
Hi, I'm trying to close and dispose a form that is running in another process, but I get the error message "A first chance exception of type 'System.ObjectDisposedException' occurred in...
4
by: MC D | last post by:
Question: If I have a class which has a property which is a collection of widget objects (an arrayList of widgets), and both the containter class and the widget class implement the IDisposable...
6
by: Catherine Jones | last post by:
Hi all, we need urgent help in a matter. We are trying to pass a COM object from the client to server and are facing some problems in the same. We've our client in C# as well as the Server...
13
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new...
8
by: MattB | last post by:
Hello I am starting a new thread in a button click event. This thread calls an method which sends emails, I don't want the page to wait for the emails to finish going out as it slows the user...
2
by: Dave | last post by:
I'm having trouble understanding dispose. I set up a class that, among other things, displays the time in a status bar panel. It does this by starting a thread. I create an instance of this...
10
by: Dennis | last post by:
I don't think I clearly stated my problem in my prior question so let me try again. I have the following: Private myobject as Bitmap myobject = mybitmap (created from a part of the screen) ...
3
by: sternr | last post by:
Hey, I have a C# assembly that inherits from ServicedComponent and is installed in the Com+ with ServerActivation. And I have a C++ application that calls this Com+ object successfully, But the...
8
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx...
29
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.