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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:14:56+00:00 2026-05-12T20:14:56+00:00

Ok, I have a winforms app and my code works fine. But I want

  • 0

Ok, I have a winforms app and my code works fine.
But I want to know if my code is bullet proof or if it only works without load.

Let me explain it:

I have a windows form where I have overridden the OnKeyDown method:

    Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)

        dim args as new ActionEventArgs(ActionType.Bark)
        RaiseEvent Action(me, args)

        e.Handled = args.Handled
        MyBase.OnKeyDown(e)

    End Sub

As you can see I raise an custom event and query the Handled Variable of it afterwards.
My Event / ActionEventArgs looks like this:

    Public Event Action(sender as Object, e as ActionEventArgs)

    Public Class ActionEventArgs
        Inherits EventArgs

        Public Handled as Boolean
        Public Action as Action
        Public Sub New(ByVal action as ActionType)
            Me.Action = action
        End Sub
    End Class

where ActionType is this Enum

    Public Enum ActionType
        Bark,
        Jump,
        FireNukeWithoutFurtherWarning
    End Enum

Now I have a class that is registered to this event and, if it knows how to handle the ActionType it sets Handled to true.

    Public Sub actionHandler(ByVal sender as Object, e as ActionEventArgs) Handles me.Action

        If e.Handled then return

        If e.Action = ActionType.Bark
            Bark()
            e.Handled = true
        End If
    End If

I tried this code at my developer machine and it seems to work. In the OnKeyDown Method, everytime I query the Handled variable, my actionHandler method did run first.
But I asking me if this is only the case because my developer machine is in idle state and the event queue is processed so fast or can I expect the

    RaiseEvent(...)

method to wait until every registered EventHandler has finished it’s taks?

  • 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-12T20:14:57+00:00Added an answer on May 12, 2026 at 8:14 pm

    Raising an event is exactly the same as calling a method (specifically, it’s calling a MulticastDelegate, which is a list of pointers to other methods, each of which will be executed); the code will process all of the event handlers before it continues to your next statement.

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

Sidebar

Related Questions

I have some code like this in a winforms app I was writing to
I have a winforms app and i want to keep track of every time
I have a WinForms app with a datagridview and a bindingsource. I want the
Problem 1: I have a simple winforms app and I want to DataBind my
I have a winForms NET3.5SP1 app, and want to POST data to a PHP
I have a WinForms app written in C# with .NET 3.5. It runs a
So we have a winforms app that in the task manager should anywhere from
I have a .net winforms app which has a few animation effects, fade ins
I have a legacy WinForms Mdi App in VB.Net 2.0 which I am adding
I have a combo box on a WinForms app in which an item may

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.