Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
AnswerRe: XML Document Reader Pin
PIEBALDconsult8-Sep-10 13:51
mvePIEBALDconsult8-Sep-10 13:51 
AnswerRe: XML Document Reader Pin
Luc Pattyn8-Sep-10 14:52
sitebuilderLuc Pattyn8-Sep-10 14:52 
GeneralRe: XML Document Reader Pin
PIEBALDconsult8-Sep-10 16:56
mvePIEBALDconsult8-Sep-10 16:56 
GeneralRe: XML Document Reader Pin
Luc Pattyn8-Sep-10 17:02
sitebuilderLuc Pattyn8-Sep-10 17:02 
GeneralRe: XML Document Reader Pin
raghavsesh8-Sep-10 23:47
raghavsesh8-Sep-10 23:47 
GeneralRe: XML Document Reader Pin
Pete O'Hanlon9-Sep-10 0:12
mvePete O'Hanlon9-Sep-10 0:12 
AnswerRe: XML Document Reader Pin
JohnLBevan9-Sep-10 1:48
professionalJohnLBevan9-Sep-10 1:48 
QuestionC# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 3:59
Keith Vitali8-Sep-10 3:59 
Hello,

I have been struggling with some threading issues over the last couple of days. I am getting close to getting this thing to work but there are still a few niggles.

So, I have a thread that is called as follows and after the thread starts, my application shows a modal dialog box. So far so good:

t = new System.Threading.Thread
    (delegate()
    {
       result = Init();
    });                
t.Start();
dialog.ShowDialog();


This works fine and there are no problems. Now, the user can hide this dialog box and when that happens the subsequent code gets executed as expected and this is not a problem. Also, I use ShowDialog(), so hiding or calling Close() should not call dispose as indicated in the docs.

Also, the dialog box is a singleton and lives for the duration of the application.

Now, my dialog box has a progress bar which gets updated by the calling thread and the update method that gets executed is as follows:

delegate void ProgressValueDelegate(int value); 
public void SetProgressValue(int value)
{
    if (this.InvokeRequired)
    {
       ProgressValueDelegate pvd = new ProgressValueDelegate(SetProgressValue);                
       this.Invoke(pvd, new object[] { value });
    }
    else
    {
       m_progressBar.Value = value;
    }
}


So, as soon as the dialog box is hidden, the subsequent call crashes at the Invoke() call. I think there is some race condition going on somewhere because in the debugger the InvoleRequired value is fasle. However, the code has already entered the 'if' condition.

Does anyone know how I can handle this sort of situation?

Thanks,
Keith
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Ennis Ray Lynch, Jr.8-Sep-10 4:07
Ennis Ray Lynch, Jr.8-Sep-10 4:07 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 4:18
Keith Vitali8-Sep-10 4:18 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Ware@Work9-Sep-10 7:26
Ware@Work9-Sep-10 7:26 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Fayu8-Sep-10 4:22
Fayu8-Sep-10 4:22 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 4:34
Keith Vitali8-Sep-10 4:34 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Fayu8-Sep-10 5:19
Fayu8-Sep-10 5:19 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Keith Vitali8-Sep-10 5:23
Keith Vitali8-Sep-10 5:23 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Chris Trelawny-Ross8-Sep-10 5:39
Chris Trelawny-Ross8-Sep-10 5:39 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
HuntrCkr9-Sep-10 1:40
HuntrCkr9-Sep-10 1:40 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Luc Pattyn9-Sep-10 3:14
sitebuilderLuc Pattyn9-Sep-10 3:14 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
HuntrCkr9-Sep-10 3:35
HuntrCkr9-Sep-10 3:35 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Luc Pattyn9-Sep-10 3:50
sitebuilderLuc Pattyn9-Sep-10 3:50 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
HuntrCkr9-Sep-10 4:04
HuntrCkr9-Sep-10 4:04 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Peter Trevor9-Sep-10 4:57
Peter Trevor9-Sep-10 4:57 
GeneralRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Luc Pattyn9-Sep-10 9:39
sitebuilderLuc Pattyn9-Sep-10 9:39 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
Fabio Franco9-Sep-10 3:44
professionalFabio Franco9-Sep-10 3:44 
AnswerRe: C# threading question: Invoke() fails with ObjectDisposedException Pin
CodeHawkz9-Sep-10 6:10
CodeHawkz9-Sep-10 6:10 

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.