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

  • Home
  • SEARCH
  • 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 8612725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:41:55+00:00 2026-06-12T04:41:55+00:00

Given static void Main() { Form f = new Form(); f.Show(); Action a =

  • 0

Given

    static void Main()
    {
        Form f = new Form();
        f.Show();
        Action a = () => MessageBox.Show("hi");            
        Task.Factory.FromAsync(f.BeginInvoke(a), (ar) => a.EndInvoke(ar));
        Console.Read();
    }
  • I never see a messagebox display “hi”.
  • Second, do I still need to call EndInvoke(ar) when using Task.Factory from Async?
  • 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-06-12T04:41:57+00:00Added an answer on June 12, 2026 at 4:41 am

    When you call a MessageBox from a thread, other then the UI thread, it will never show up.

    The correct way to handle this, is to raise an event from the method you’re calling on another thread, and let the UI thread subscribe to it. In the eventhandler, you can write code to display the MessageBox.

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

Sidebar

Related Questions

Given the code below: static void Main() { Console.WriteLine(typeof(MyEnum).BaseType.FullName); } enum MyEnum : ushort
Given the following sample code; class Program { static void Main(string[] args) { var
Given the class below, public class ClassOne { public static void main(String... args) {
Given: import java.util.*; public class Quest { public static void main(String[] args) { String[]
Given the following code: using System.Collections.Generic; static class Program { static void Main() {
Given this method call: public class MainClass { public static void main(String[] args) {
Given the following code: namespace GcDemo { class Program { static void Main(string[] args)
Given the following code : import java.io.*; public class Main { public static void
Given this piece of code : public static void writeFile(File file,List buffer)throws IOException{ File
import java.io.*; import java.util.*; public class Sort { public static void main(String[] args) throws

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.