Click here to Skip to main content
15,919,434 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon24-May-10 5:01
Jacob Dixon24-May-10 5:01 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 5:06
sitebuilderLuc Pattyn24-May-10 5:06 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. [modified] Pin
Jacob Dixon24-May-10 5:26
Jacob Dixon24-May-10 5:26 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 6:23
sitebuilderLuc Pattyn24-May-10 6:23 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon24-May-10 6:41
Jacob Dixon24-May-10 6:41 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 6:54
sitebuilderLuc Pattyn24-May-10 6:54 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon24-May-10 7:13
Jacob Dixon24-May-10 7:13 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 7:27
sitebuilderLuc Pattyn24-May-10 7:27 
1. DoEvents() is evil because it adds re-entrancy to your code: pieces of code that were never going to be executed twice at the same time could suddenly run twice. Example:

public void Button_Click(...) {
    long-wielding calculation
    // Application.DoEvents();
    more long-wielding calculation
}


in the above, the GUI is dead as long as the calculations keep the GUI thread occupied. Inserting one or more DoEvent() calls, causes the message pump to get pumping again; now if you had clicked the same button, the same handler would suddenly run for a second time. And the handler's code was not designed in a thread-safe way as it was never expected to run concurrently. Each run would have its own set of local variables (as they are on stack, there is a stack for each thread), however the object's state, as maintained in the class data, could easily become inconsistent and invalid.

2.
I did not suggest modifying things that look fine; your Invoke (or one of its alternatives), while essential for things to go wrong, is not the cause of the problem.

3.

Jacob Dixon wrote:
you have to be trying to make it break for it to throw the error (which is what I'm doing


Trying to break it is part of quality assurance; abuse is a must at that time!
If it were to fail when used normally, now that would really be unacceptable.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read formatted code with indentation, so please use PRE tags for code snippets.

I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).

Questiontype object Pin
tek 200923-May-10 10:32
tek 200923-May-10 10:32 
AnswerRe: type object Pin
Pete O'Hanlon23-May-10 10:46
mvePete O'Hanlon23-May-10 10:46 
AnswerRe: type object Pin
tek 200923-May-10 12:28
tek 200923-May-10 12:28 
QuestionOutput type of Class Library cannot be started directly Pin
tan_chin23-May-10 9:33
tan_chin23-May-10 9:33 
AnswerRe: Output type of Class Library cannot be started directly Pin
#realJSOP23-May-10 9:58
professional#realJSOP23-May-10 9:58 
GeneralRe: Output type of Class Library cannot be started directly Pin
tan_chin23-May-10 10:28
tan_chin23-May-10 10:28 
GeneralRe: Output type of Class Library cannot be started directly Pin
Dave Kreskowiak23-May-10 18:26
mveDave Kreskowiak23-May-10 18:26 
AnswerRe: Output type of Class Library cannot be started directly Pin
Pete O'Hanlon23-May-10 10:00
mvePete O'Hanlon23-May-10 10:00 
GeneralRe: Output type of Class Library cannot be started directly Pin
tan_chin23-May-10 10:29
tan_chin23-May-10 10:29 
QuestionExcel number of rows Pin
gmhanna23-May-10 7:37
gmhanna23-May-10 7:37 
AnswerRe: Excel number of rows Pin
Abhinav S23-May-10 7:42
Abhinav S23-May-10 7:42 
QuestionArraylist Goes Null after Passing information back to Main Page from Window. Pin
PDTUM23-May-10 7:23
PDTUM23-May-10 7:23 
AnswerRe: Arraylist Goes Null after Passing information back to Main Page from Window. Pin
Abhinav S23-May-10 7:38
Abhinav S23-May-10 7:38 
GeneralRe: Arraylist Goes Null after Passing information back to Main Page from Window. Pin
PDTUM23-May-10 8:28
PDTUM23-May-10 8:28 
GeneralRe: Arraylist Goes Null after Passing information back to Main Page from Window. Pin
OriginalGriff23-May-10 9:05
mveOriginalGriff23-May-10 9:05 
GeneralRe: Arraylist Goes Null after Passing information back to Main Page from Window. Pin
OriginalGriff23-May-10 9:08
mveOriginalGriff23-May-10 9:08 
GeneralRe: Arraylist Goes Null after Passing information back to Main Page from Window. Pin
PDTUM23-May-10 9:16
PDTUM23-May-10 9:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.