Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 373193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:17:04+00:00 2026-05-12T14:17:04+00:00

I have an interesting problem.. I have a Form that launches another Form (2)

  • 0

I have an interesting problem..
I have a Form that launches another Form (2) through a Button. Before Form2 Closes, it sometimes fires an Event which Invalidates Form 1 and forces Form 1 to refresh it’s data. The problem I have is After Form 2 fires the event, Form 1 seems to get it and handles it, and refreshes it’s data and Only then Form 2 Closes. I want Form 2 to Fire the event and Close, BEFORE Form1’s event handler catches and processes the event.
I have a feeling it is related to BackgroundWorker (sort of like SwingUtilities.InvokeLater in Java) .. but I am not that experienced with it ..

public class Frm1{

void LaunchForm2(){
   Frm2 form2 = new Frm2();
   form2.dataChanged += new DataChangeListener(myListener);
   form2.showDialog();
}
private void myListener(){
  //get my data again
}

}

public class Frm2{

 private void Close(){
    if(myDataHasChanged){
      if(dataChanged != null) { 
        dataChanged(); 
      }
      this.Close();
    }
 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:17:04+00:00Added an answer on May 12, 2026 at 2:17 pm

    You can raise the event after calling Close – calling Form.Close will not exit the method that called it.

    EDIT: Try using BeginInvoke to wait for the next message loop before handling the event, like this:

    form2.dataChanged += delegate { BeginInvoke(new DataChangeListener(myListener)); };
    

    2nd EDIT: To give Form1 a chance to repaint, call BeginInvoke twice to wait two message loops before updating (One to close Form2, and a second to repaint Form1), like this:

    form2.dataChanged += delegate(parameters) { 
        BeginInvoke(new Action(delegate { 
            BeginInvoke(new DataChangeListener(myListener), parameters);
        }));
        //Or,
        BeginInvoke(new Func<Delegate, object[], IAsyncResult>(BeginInvoke),
                    new object[] { parameters }
        );
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting problem. The basis of the problem is that my last
I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
I ran into an interesting problem. I have a MySQL database that contains some
We have an interesting problem that I was hoping someone could help to shed
PHP mySQL Hi, i am having an interesting problem. I have a form in
I have an interesting problem that seems to be eluding me. Mono's xsp4 only
I have an interesting problem that I'm trying to solve and was wondering if
I have an interesting problem here... <cfloop from=1 to=#form.countField# index=i> <cfif isdefined('form[semester#i#]')> <cfquery name
I have an interesting problem and would appreciate your thoughts for the best solution.
I have one interesting problem. I must parse mail body (regular expression), get some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.