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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:33:59+00:00 2026-05-14T03:33:59+00:00

In physics library written in C# I have the following code: (in ContactManager.cs) public

  • 0

In physics library written in C# I have the following code:

(in ContactManager.cs)

public delegate void PostSolveDelegate(Contact contact, ref ContactImpulse impulse);
public PostSolveDelegate PostSolve;

And an example that uses that code is:

(in Test.cs)

public virtual void PostSolve(Contact contact, ref ContactImpulse impulse)
{
}

ContactManager.PostSolve += PostSolve;

I’d like to do the same in VB. (just thandling the delegate, not the declaration)

I tried this, but it doesn’t work:

AddHandler ContactManager.PostSolve, AddressOf PostSolve

The following works, but only allows me to have one handler for the delegate:

ContactManager.PostSolve = new PostSolveDelegate(AddressOf PostSolve)

Is there a way for me to do the same thing in VB that was done in the first piece of code?

Thanks!

  • 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-14T03:33:59+00:00Added an answer on May 14, 2026 at 3:33 am

    A delegate can be a multicast delegate. In C# you can use += to combine multiple delegates into a single multicast delegate. Usually you see this done as an event and then use AddHandler in VB to add multiple delegates to the event.

    But if you did something like this:

    Public Delegate Sub PostSolver()
    

    and then declared the field in a class:

    Private PostSolve As PostSolver
    

    and then created two delegates and used Delegate.Combine to combine them:

    Dim call1 As PostSolver
    Dim call2 As PostSolver
    call1 = AddressOf PostSolve2
    call2 = AddressOf PostSolve3
    
    PostSolve = PostSolver.Combine(call1, call2)
    

    You can call PostSolve() and both delegates will be called.

    Might be easier just to make it an Event which is setup to do this without the extra hassle.

    Update: To remove a delegate from the list you use the Delegate.Remove method. But you must be careful to use the return value as the new multicast delegate or it will still call the delegate you thought you removed.

    PostSolve = PostSolver.Remove(PostSolve, call1)
    

    Calling PostSolve will not call the first delegate.

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

Sidebar

Related Questions

I have written some physics simulation code in C++ and parsing the input text
We are designing physics app, and we would like to have it written in
My project involves Qt plus and unnamed 3rd party physics simulation library. The way
Can anyone point me to a library for 2D game physics, etc for programming
In a C++ physics simulation, I have a class called Circle, and Square. These
I have a physics simulation and it allows you to place area constraints, so
I was browsing some documentation for a physics library for XNA and noticed an
Have looked so long for a library specialized in dealing with iPhone Accelerometer but
I have bullet physics set up and working on the iPhone but now I
I'm creating a minimal circle-circle physics engine in a static library, and I've came

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.