Noob coding help! (1 Viewer)

eggyman

Portal Member
February 21, 2010
10
0
Hi all.
I'm just starting out looking into my first MP related code and i've become a bit stuck.

What i want to do is show a progress dialog popup over the current window but have have the code continue processing with the dialog showing.
I'm not a C# developer so forgive me if this is dumb.

This is what i've got at the moment:

GUIDialogProgress dlgProgress =(GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
if (dlgProgress != null)
{
dlgProgress.SetHeading("blah...");
dlgProgress.SetPercentage(0);
dlgProgress.Progress();
dlgProgress.ShowProgressBar(false);
GUIWindowManager.Process();
dlgProgress.DoModal(GUIWindowManager.ActiveWindow);
}


Now this shows a dialog window, but any code after DoModal doesn't run until the cancel button is pressed.
I tried StartModal, which doesn't show a window at all.

I'm struggling a bit here!

:D
 

Baboonanza

Retired Team Member
  • Premium Supporter
  • February 5, 2010
    143
    57
    North London
    Home Country
    United Kingdom United Kingdom
    I'm not a C# developer either (yet!), but I can tell you that runnig a dialog as modal on Windows always means that it blocks execution of the code (in the current thread) until the dialog closes. This is often a usefull feature. If you want other behaviour you need to open the window in a way that doesn't have 'Modal' in the name :)

    Beyond that I can't help.
     

    bryanchicken

    Portal Member
    April 21, 2009
    21
    0
    Thanks Baboonanza. That makes sense.

    The problem being that the only way i could find of actually getting a window to appear was with that method :mad: The frustrating thing is that i'm sure its easy once you know how!

    Currently i've progressed by starting another thread for my behind the scenes processing, but i can't help but think that i'm overkilling the situation somewhat by doing it that way.

    Cheers.
     

    Inker

    Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Please don't crosspost.

    Threads are your friend here. Easiest is probably a Backgroundworker, but we dont know what you are trying to achieve exactly, but its probably a good start.
     

    Users who are viewing this thread

    Top Bottom