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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:16:07+00:00 2026-06-06T03:16:07+00:00

I have a windows form where in I open new threads for server communication.

  • 0

I have a windows form where in I open new threads for server communication.
I need to write in the form (in a textbox) how the server has responded to the query.

At the moment I do the server communication as follows:

ServerClass SC = new ServerClass(param);
new Thread(new ThreadStart(SC.serverAction)).Start()

The serverAction as it is now, is a void method within the ServerClass class, but I can ofcourse make that return a value if needed. However Im leaning more to delegates, but im not quite sure how to call back from the other thread…

The ServerClass is a simple class using WCF as follows:

public class ServerClass
{
  private string var1;
  private string var2;

  public ServerClass(string var1, string var2)
  {
    this.var1 = var1; this.var2 = var2;
  }
  public void serverAction()
  {
    //WCF here
  }
}

Any suggestions how I can get a value from the “serverAction()” method?

  • 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-06T03:16:09+00:00Added an answer on June 6, 2026 at 3:16 am

    Well, you can’t exactly return a value from the thread’s entry point.
    What I would suggest is some kind of async communication between the Server class.

    You can define an event in your Server class, something like:

    public event EventHandler<YourEventInformation> OnServerConnected = (s, e) => {};
    

    Then, when serverAction is ready, you do something like:

    YourEventInformation evtInfo [= new YourEventInformation();
    evtInfo.CustomReturnValue = "something here";
    
    //Async call in the UI thread
    OnServerConnected.BeginInvoke(this, evtInfo, null, null);
    

    Next, you need to bind to this event from somewhere from the UI (probably the Window).
    There you need to just call your code in the UI thread’s context, by first checking Dispatcher.CheckAccess and then invoking your UI code.
    Something very similar with what is described here.

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

Sidebar

Related Questions

I have two windows forms. I need to open second form in each adjusted
I have window form in my WPF Application when I open new window from
I have a Windows Form with a ListBox. The form has this method public
I have a windows form project with a main form. There is a textbox
I have a Windows Form application. Version 1 of my app has been released
I have a windows form application that will open other forms, but will only
I have a windows form with a text box txtOutput . I have some
I have a windows form that I am using a microsoftreportviewer on and I
I have a windows form on the main thread and another thread that does
I have a windows form with DataBound DataGrid on it. Bound to a list

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.