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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:03:08+00:00 2026-05-23T08:03:08+00:00

This is the second question in a series concerning updating the UI from another

  • 0

This is the second question in a series concerning updating the UI from another thread. I am trying to use a delegate to tell the UI to execute the update function (no data needs to be passed). I created a delegate in the UI thread and declared it on top of the UI thread:

delegate void MyDel();
public ref class Form1 : public System::Windows::Forms::Form
{
    // .....
    void testFunc()
    {
       this->local_long_textBox->Text = "Test!!!!!!!";
    }
private:
    void startUp()
    {
       MyDel^ DelInst = gcnew MyDel(this,&CotStinger::Form1::testFunc);

I would like to pass DelInst to another thread upon creation but when I try to declare MyDel as an extern like this on top of another module:

extern delegate MyDel;

I get the error:

Error C2146: syntax error : missing ';' before identifier 'MyDel'.

If I try this

extern delegate void MyDel();

I get the error:

Error C2144: syntax error : 'void' should be preceded by ';'

So how do I get the other class to recognize the delegate type so I can pass the delegate pointer to the constructor?

  • 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-23T08:03:09+00:00Added an answer on May 23, 2026 at 8:03 am

    The delegate keyword is used to define a delegate type, not to declare a variable that happens to be some type of delegate. I.e., once the delegate type has been defined, you don’t need the delegate keyword at any point.

    Additionally, global variables of managed types are not allowed in C++/CLI; the usual workaround is to use a logically-static managed class with public static data members that function as globals:

    delegate void MyDel();
    private ref struct Globals abstract sealed
    {
        static MyDel^ MyDelInstance;
    };
    
    // ...
    
    Globals::MyDelInstance = gcnew MyDel(this, &CotStinger::Form1::testFunc);
    

    So how do I get the other class to recognize the delegate type so I can pass the delegate pointer to the constructor?

    The same as with any other type — put it in a header file that both classes can #include.

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

Sidebar

Related Questions

This is a second-hand question from an OS development site, but it made me
I've got a Perl script that needs to execute another Perl script. This second
This is my second question on Bamboo ( My First One ). My understanding
I hope it's the heat, this is the second question today and it's one
So, my second question based off of this application I'm teaching myself Objective C
Sorry for the second newbie question, I'm a developer not a sysadmin so this
(Hope this doesn't get duplicated; second attempt at submitting this question) I'm working on
I've a application that must work after another application. This second application has a
This is the second part of a series of educational regex articles. It shows
Ok, I need something like this: datediff(second, date_one, date_two) < 1 dates are stored

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.