473,394 Members | 1,640 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,394 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 807

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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.