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 4091830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:24:57+00:00 2026-05-20T19:24:57+00:00

In a C# winforms program, I have an event that fires when someone attempts

  • 0

In a C# winforms program, I have an event that fires when someone attempts to rename a project. In the EventArgs for that event, I have a “Cancel” property that the event listeners can set to true to (ideally) cancel the rename (if the name is already in use, for example):

ProjectRenamedEventArgs args = new ProjectRenamedEventArgs(oldName, newName);

if (NameChanged != null)
    NameChanged(this, args);

if (args.Cancel)
{
    // Cancel
}
else
{
    // Continue
}

The problem is, the “if (args.Cancel….” line is never reached. I’m guessing that execution is continuing right after the event is fired, and thus args.Cancel is always false so the rename always happens. How would I make execution halt until all of the event listeners have finished their work (giving args.Cancel a chance to be set to true).

I am assuming this is possible because many of the windows forms EventArgs have a Cancel property that allow for whatever just happened to be cancelled (changing the label on a TreeView’s TreeNode, for example).

  • 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-20T19:24:58+00:00Added an answer on May 20, 2026 at 7:24 pm

    You say: “The problem is, the ‘if (args.Cancel….” line is never reached’

    This tells me that your event handler(s) wired to NameChanged are not returning. Another possibility is that one of these handlers is throwing an unhandled exception, and the above code in your example is swallowing the exception.

    -Oisin

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

Sidebar

Related Questions

I have a winforms program which have an Exit button which fires an event
In my C# WinForms program, I have a form that has only a single
How can I have a WinForms program do some specific thing whenever a certain
I have a C# Winforms program with multiple textboxes. I used the properties for
I have a method in my C# WinForms program, which checks if X column
I have an OCR program, written with C# (WinForms app). So it's main purpose
I have a winform program that uses Merge Replication to keep a local SQL
this can be asked with webform or winform... i have a .net program (exe)
I have a progaram that can be ran both as a winform, or from
I have a winforms c# app that has an embedded webbrowser control inside it

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.