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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:54:06+00:00 2026-05-30T18:54:06+00:00

I have an algorithm that always runs steps A, C, D in that order.

  • 0

I have an algorithm that “always” runs steps A, C, D in that order.

I want to allow a way to run A, B, C, D, where B can be multiple methods. C, D “should” be unaffected, but I cannot parallelize it. It is just writing to a file.

Any way, I know a tiny bit about delegates and have used the AddressOf to hook up an event handler.

So I was thinking of simply creating an array or collection of what not of “addresses” or delegates.

Is this even possible?

Is this the ‘best’ way? I know how to force the behavior with objects, but I am hoping to reuse any mechanisms already built in to VB, .NET.

Dane

  • 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-30T18:54:07+00:00Added an answer on May 30, 2026 at 6:54 pm

    You could simply use an event to store and invoke multiple methods. Events are basically streamlined multicast delegates, so you won’t have to use Delegate.Combine. The drawback is that your methods won’t be able to have return types.

    Here’s an alternative way to use multicast delegates, as well. This example assumes you want a value to be returned from the methods. If you don’t need this, you won’t have to loop through the methods; you can just use myMethods.Invoke.

    'the methods will be stored here
    Private _MyMethods As [Delegate]
    
    'this is here to show the signature of the methods
    Public Delegate Function MyMethod(ByVal input As String) As String
    
    Public Sub AddMethod(ByVal method As MyMethod)
        _MyMethods = [Delegate].Combine(_MyMethods, method)
    End Sub
    
    Public Sub RemoveMethod(ByVal method As MyMethod)
        _MyMethods = [Delegate].Remove(_MyMethods, method)
    End Sub
    
    Public Sub InvokeMethods(ByVal input As String)
        If _MyMethods Is Nothing Then Return
    
        Dim myMethods As MyMethod = DirectCast(_MyMethods, MyMethod)
    
        'since you'll want the return value of each methods, loop through the methods
        For Each method As MyMethod In myMethods.GetInvocationList()
            Dim value As String = method.Invoke(input)
    
            'TODO: something with the value
        Next
    End Sub
    

    As another alternative to that invocation code above, you could use the Delegate.DynamicInvoke method to not have to cast the delegate. That, however, would use late-binding, and, in the case of a function, would require the return value to be cast anyway.

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

Sidebar

Related Questions

I have found out that my algorithm will always do n!*4^n steps . I'd
I have this algorithm that I want to implement on VB6. Sub Main() dim
If I have an algorithm that takes n log n steps (e.g. heapsort), where
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily
If I have three points and always want the visible face should be the
I have an algorithm that attempts to solve SAT, and I believe it always
I have an algorithm that generates strings based on a list of input words.
I have an algorithm that recursively makes change in the following manner: public static
I have a two part question Best-Practice I have an algorithm that performs some
I have a SP that has the following algorithm. IF <SomeCondition> BEGIN SELECT *

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.