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

  • SEARCH
  • Home
  • 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 975123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:32:05+00:00 2026-05-16T03:32:05+00:00

Well I’m using a Window as my custom message box with a couple of

  • 0

Well I’m using a Window as my custom message box with a couple of controls which are displayed/populated with text depending on which constructor is called.

I have a defined event, which is subscribed to via the original class, this fires once the button has been clicked.

However I can’t see how to use this effectively, preferably I’d like to return a bool whether Yes or No was clicked, however obviously my code will carry on executing, hence the method which is subscibed to the button click. Below is some example code to make the issue clearer.

Message Box Window

public partial class CustomMessageBox : Window
    {

        public delegate void MessageBoxHandler(object sender, EventArgs e);
        public event MessageBoxHandler MessageBoxEvent;

        public CustomMessageBox()
        {
            InitializeComponent();
        }

        public CustomMessageBox(string message)
        {
            InitializeComponent();
            this.txtdescription.Text = message;
        }

        public CustomMessageBox(string message, string title, string firstBtnText)
        {
            InitializeComponent();
            this.lbltitle.Content = title;
            this.txtdescription.Text = message;
            this.btnstart.Content = firstBtnText;
        }

    }

    public static class MessageBoxButtonClick
    {

        public static bool Yes { get; set; }
        public static bool No { get; set; }
        public static bool Cancel { get; set; }
    }

Window Which Instantiates the MessageBox Window

private void StartProcess_Click(object sender, System.Windows.RoutedEventArgs e)
        {

            foreach (var result in results)
            {
                if(result.ToBeProcessed)
                    _validResults.Add(new ToBeProcessed(result.Uri, result.Links));

            }
            _msgbox = new CustomMessageBox("Each Uri's backlinks will now be collected from Yahoo and filtered, finally each link will be visited and parsed. The operation is undertaken in this manner to avoid temporary IP Blocks from Yahoo's servers.", "Just a FYI", "OK");
            _msgbox.MessageBoxEvent += (MessageBoxHandler);

            if (_msgBoxProceed)
            {
                _msgbox.Close();
                Yahoo yahoo = new Yahoo();

                yahoo.Status.Sending += (StatusChange);

                //What I'd like to happen here is the code simply stop, like it does when calling a messagebox is winforms
                //e.g. 
                // if(ProceedClicked == true)
                // do stuff

               // yahoo.ScrapeYahoo(_validResults[Cycle].Uri, _validResults[Cycle].LinkNumber);

                //Cycle++;
            }
            else
            {
                _msgbox.Close();
            }

        }

private void MessageBoxHandler(object sender, EventArgs e)
        {
            if (MessageBoxButtonClick.Yes)
            {
                ProceedClicked = true;
            }
            else
            {
                ProceedClicked = false;
            }
        }

Hopefully that makes it clear enough, I can’t put any execution code ie call a certain method due to using it multiple times throughout my application.

  • 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-16T03:32:06+00:00Added an answer on May 16, 2026 at 3:32 am

    Very hard to understand what the problem exactly is. Also the code you wrote here, doesn’t seemt to have any calls, that would actually show the CustomMessageBoxWindow.

    But I’ll take a stab at this…
    First of all, am I right in guessing that in your main Window you want your code to wait at if(_msgBoxProceed) until the user actually presses a button in your CustomMessageBoxWindow (currently it just shows the message box and continues executing the next statements)?

    If so then I’m guessing you are showing your message box window with the Show() method. Use ShowDialog() instead. That will cause code execution to stop, until the message box gets closed.

    If you don’t want to use a modal dialog then there are two options. Either use thread syncrhonization objects (eg AutoResetEvent) or set up a new event for when the message box closes and continue your code execution in the closed event handler (in StartProcess_Click the last line would be a call to _msgBox.Show() and everything from if(_msgBoxProceed) would be in the closed event handler).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.