Click here to Skip to main content
15,905,875 members
Home / Discussions / C#
   

C#

 
AnswerRe: Hiding/Showing panels Pin
Dave Kreskowiak8-Sep-10 18:08
mveDave Kreskowiak8-Sep-10 18:08 
AnswerRe: Hiding/Showing panels Pin
The Man from U.N.C.L.E.9-Sep-10 7:34
The Man from U.N.C.L.E.9-Sep-10 7:34 
AnswerRe: Hiding/Showing panels Pin
Megidolaon9-Sep-10 8:15
Megidolaon9-Sep-10 8:15 
GeneralRe: Hiding/Showing panels Pin
OriginalGriff9-Sep-10 8:51
mveOriginalGriff9-Sep-10 8:51 
GeneralRe: Hiding/Showing panels Pin
Luc Pattyn9-Sep-10 13:47
sitebuilderLuc Pattyn9-Sep-10 13:47 
GeneralRe: Hiding/Showing panels Pin
Megidolaon9-Sep-10 14:42
Megidolaon9-Sep-10 14:42 
GeneralRe: Hiding/Showing panels Pin
Luc Pattyn9-Sep-10 14:51
sitebuilderLuc Pattyn9-Sep-10 14:51 
GeneralRe: Hiding/Showing panels Pin
Megidolaon9-Sep-10 17:49
Megidolaon9-Sep-10 17:49 
Question10 band equalizer using DIRECTX in C# Pin
Nishad Ullaskumar P8-Sep-10 7:28
Nishad Ullaskumar P8-Sep-10 7:28 
AnswerRe: 10 band equalizer using DIRECTX in C# Pin
Dave Kreskowiak8-Sep-10 10:32
mveDave Kreskowiak8-Sep-10 10:32 
AnswerRe: 10 band equalizer using DIRECTX in C# [ignore] Pin
Ravi Bhavnani9-Sep-10 9:00
professionalRavi Bhavnani9-Sep-10 9:00 
QuestionXML Document Reader [modified] Pin
raghavsesh8-Sep-10 5:58
raghavsesh8-Sep-10 5:58 
AnswerRe: XML Document Reader Pin
Richard MacCutchan8-Sep-10 7:24
mveRichard MacCutchan8-Sep-10 7:24 
GeneralRe: XML Document Reader Pin
raghavsesh8-Sep-10 23:22
raghavsesh8-Sep-10 23:22 
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 

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.