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

The Archive Base Latest Questions

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

I am using Visual C++ 2008 with CLI. I have a form with a

  • 0

I am using Visual C++ 2008 with CLI. I have a form with a textbox and a button, once i press the button i want the following code to output as follows:

private:

System::Void button_Click(System::Object^  sender, System::EventArgs^  e) {
    Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&Form1::calculate("t1")));
    Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&Form1::calculate("t2")));
    thr1->Start();
    thr2->Start();
 }

void calculate(String^ val) {
    int j;
for(j=0; j<10; j++)
    _txt->AppendText(val  + Convert::ToString(j) + "\n");
}

Desired output:

t1 0
t2 0
t1 1
t2 1

etc…

My code above does not work. Stating that i the delegate requires two inputs at the gcnew Thead line. What am i doing wrong? Also is there a better way to achieve this?

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

    I will punt on the compilation error since C++\CLI is not a familar language to me. However, I can mention another problem.

    You are attempting to access a UI control from a non-UI thread. You cannot touch _txt in any way shape or form (even just reading a property) from a worker thread or any other thread except for the main UI thread. What you can do is marshal the execution of a delegate back onto the UI thread and from that you can change the Text property or call AppendText. To marshal a delegate onto the UI thread use _text->Invoke.

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

Sidebar

Related Questions

I have C++/CLI code and I'm using Visual Studio 2008 Team Suite Code Coverage.
I am using Visual Studio 2008. I have created a visual basic form that
I have created a website using visual studio 2008. Now i want to run
Using Visual Studio 2008 / C# / VS Unit Testing. I have a very
Using visual studio 2008. When I add a new aspx form to a project
Using Visual Studio 2008, c#, .net 2.0. I have a Windows Forms client application
Im using Visual studio 2008. Every once in a while files that exist in
I'm using Visual Studio 2008, with .net framework, C++/CLI. My program only runs in
I'm mystified: I'm using Visual Studio 2008 with C++ (non-CLI), and I can't for
Using Visual Studio 2008, windows forms, C#, .NET 2.0 ... Is there a code-less

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.