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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:57:22+00:00 2026-05-26T15:57:22+00:00

Ok, so i have got myself completely stuck. My search skill are lacking and

  • 0

Ok, so i have got myself completely stuck. My search skill are lacking and I cant find anything that makes me see what I need to do.

What I have is a Telnet App. Form1 connects and preforms the socket stuff though a class. The class is refernced on form one like so

//form1
telnet tc;

private void connect_Click(object sender, EventArgs e)
{
  tc = new telnet (IP, Port);
}

What I am trying to do is use this same method on form2. form2 is a configuration window and requires getting data from the telnet server to save to an xml file. via

 //form 1
 tc.read();

I could call a new instance of the telnet class but that would be a waste of resources and I think there’s a better way to code it.

So what I would like to know is, while in form2. How do I tell a button click event to access tc from form1?

So far I haven’t been able to figure out how to get the reference of form1 tc, or the connect_click button onto form 2.

 //form2
 private void read_click(object sender, EventArgs e)
 {
   tc.read();  // how do i call it? or even call a method of form 1 to button click?
   ... write data from tc.read()
  }
  • 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-26T15:57:22+00:00Added an answer on May 26, 2026 at 3:57 pm

    One option is to create a singleton object that owns communications.

    http://msdn.microsoft.com/en-us/library/ff650316.aspx

    So, if you had something like:

    public class Communicator
    {
        Telnet m_telnet;
    
        private static Communicator instance;
    
        private Communicator() {m_telnet = new Telnet()}
    
        public static Communicator Instance
        {
            get {
                if (instance == null) {
                    instance = new Communicator();
             }
             return instance;
         }
    
         public string DoSomething()
         {
             return m_telnet.DoSomething();
         }
       }
    }
    

    Then, in your form functions you could just:

    Communicator.Instance.DoSomething();
    

    Since different forms are accessing this object, shouldn’t need to be thread safe. If it does, then you can use a double lock pattern.

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

Sidebar

Related Questions

I have the following code and got myself confused: I have a query that
Have got an NSString *str = @12345.6789 and want to find out if there
I have got a Wavecom Supreme GSM modem. I wrote a simple application that
I have got a field that has been setup to allow for Null, but
I have got an ActiveX Control that gets an image from a fingerprint device
I have got a demo script that lets me authorize with my app and
I have got a JComponent. The paintComponent method is overridden. I mentioned that tooltips
Okay, this is quite an interesting challenge I have got myself into. My RegEx
I have some experience with XSLT but now i've got myself a problem: I
I've got a database that is mirrored using SQL 2008 Mirroring. I have a

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.