G
Guest
I have a method that gets a screen of user input. The method has this in it:
public static bool getscrn(ScreenData SD)
{
GetForm form1 = new GetForm(SD);
form1.ShowDialog();
if (form1.DialogResult == DialogResult.OK)
return true;
else
return false;
}
Generally this works fine, the user enters their input into the screen,
presses OK or cancel, and the application keeps running. But sometimes it
fails, if there are two calls in a row, like this:
if(getscrn(SD1)){
var=true;
}
if(getscrn(SD2){
etc.
}
In this case, sometimes, if the user pressed Cancel on the first getscrn()
call, then the second call fails, it flashes the input screen up for a
moment, then returns to the application, with a status as if the user had
pressed Cancel in the second call also. If they press OK in the first call,
everything is fine, the second asks for input. And in some of my
applications, it works after a Cancel, in others it fails. If I put a
MessageBox.Show() in between the getscrn() calls, everything is always fine,
it waits for the MessageBox response and the getscrn() response.
So something seems to be being set in the first call, that is affecting the
second call, but I can not figure out what. There is no static data in
GetForm(), I dispose of the resources before getscrn() is complete.
Any suggestions about what the problem could be would be appreciated. Thanks.
public static bool getscrn(ScreenData SD)
{
GetForm form1 = new GetForm(SD);
form1.ShowDialog();
if (form1.DialogResult == DialogResult.OK)
return true;
else
return false;
}
Generally this works fine, the user enters their input into the screen,
presses OK or cancel, and the application keeps running. But sometimes it
fails, if there are two calls in a row, like this:
if(getscrn(SD1)){
var=true;
}
if(getscrn(SD2){
etc.
}
In this case, sometimes, if the user pressed Cancel on the first getscrn()
call, then the second call fails, it flashes the input screen up for a
moment, then returns to the application, with a status as if the user had
pressed Cancel in the second call also. If they press OK in the first call,
everything is fine, the second asks for input. And in some of my
applications, it works after a Cancel, in others it fails. If I put a
MessageBox.Show() in between the getscrn() calls, everything is always fine,
it waits for the MessageBox response and the getscrn() response.
So something seems to be being set in the first call, that is affecting the
second call, but I can not figure out what. There is no static data in
GetForm(), I dispose of the resources before getscrn() is complete.
Any suggestions about what the problem could be would be appreciated. Thanks.