Purge Event Queue??

H

HyperX

Hey guys,

Windows FOrms, .NET v1.1.

Lets say there are 2 events in the event queue.

1. Current focus is on a textbox txt1 on inherited form. User presses
F12, calls SaveRecord() Method.
2. SaveRecord() calls txt1_Leave() method.


ParentForm()
{
...
...
SaveRecord();
...
...


public void SaveRecord()
{
this.selectnextcontrol(true,true,blah, blah);
//the above line calls txt1_Leave() method.
...
...
...
}
}




InheritedForm()
{
...
...

public void txt1_Leave()
{
if (aa == bb) //some condition to cancel executing further
SaveRecord()
{
//
//HOW DO I PURGE THE SaveRecord() event HERE??
//cancel executing SaveRecord()
//
}
}
}


I know this could've been written in several ways... we are sooo deep
down in this design that there is no other way that we could fix this
other than cancelling executing SaveRecord() method.

Can anyone please help?

Thanks,

HyperX.
 
S

Sijin Joseph

That code caused a stack overflow in my head.

Try this, in the base form

ParentForm
{

protected
bool isSaving = false;

SaveRecord()
{
isSaving = true;
...
..
..
isSaving = false;
}


InheritedForm
{

txt1_leave()
{
//If we are already in SaveRecord then do not execute any further
if(this.isSaving)
return;
....
SaveRecord();
..
..

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top