Click here to Skip to main content
15,894,343 members
Home / Discussions / C#
   

C#

 
GeneralTogle acheckbox Pin
picasso27-Jan-05 18:06
picasso27-Jan-05 18:06 
GeneralRe: Togle acheckbox Pin
Matt Gerrans7-Jan-05 20:53
Matt Gerrans7-Jan-05 20:53 
GeneralRe: Togle acheckbox Pin
Luis Alonso Ramos8-Jan-05 12:34
Luis Alonso Ramos8-Jan-05 12:34 
GeneralAnyone know any good resources (besides codeproject :P) that deal with collections for use in custom controls Pin
FocusedWolf7-Jan-05 17:46
FocusedWolf7-Jan-05 17:46 
GeneralRe: Anyone know any good resources (besides codeproject :P) that deal with collections for use in custom controls Pin
ACorbs8-Jan-05 9:33
ACorbs8-Jan-05 9:33 
GeneralRe: Anyone know any good resources (besides codeproject :P) that deal with collections for use in custom controls Pin
FocusedWolf8-Jan-05 16:48
FocusedWolf8-Jan-05 16:48 
GeneralForm and Network Listener Pin
Jackson L7-Jan-05 16:05
sussJackson L7-Jan-05 16:05 
GeneralRe: Form and Network Listener Pin
Allan Eagle8-Jan-05 14:40
Allan Eagle8-Jan-05 14:40 
Yes you are correct. The code is halting within Form1.Run() (called from the constructor) so execution never reaches Application.Run(new Form1()), which is the reason you never see the form open.

To acheive the result you require can be acheived by running the Form1.Run() method as a seperate worker thread which can be achieved something like:-

public class Form1 : System.Windows.Forms.Form
{
  private Thread trdTcpActivityListener = null;

  public Form1()
  {
     InitializeComponent();

     // Initialize seperate thread and start it
     trdTcpActivityListener = new Thread(new ThreadStart(this.Run));
     trdTcpActivityListener.Start();      
      
     // Instead of - this.Run();
  }

  public void Run()
  {
    TcpListener tcpListener = new TcpListener(IPAddress.Any, 65000);
    tcpListener.Start();

    while (true)
    {
      // Use .Pending() to determine if there is any connections
      if (tcpListener.Pending())
      {
	Socket socketForClient = tcpListener.AcceptSocket();
        socketForClient.Close();
	// Maximize the form
	this.WindowState = FormWindowState.Maximized;      
      }

      // Make sure the while loop doesn't hog the CPU
      Thread.Sleep(30);
    }
  }
}


Now whilst the worker thread waits for a TCP connection, the main thread is allowed to continue,
the constructor completes and the form opens (minimized). Ill leave it up to you to work out when you should stop the worker thread.
GeneralRe: Form and Network Listener Pin
Member 14535649-Jan-05 15:45
Member 14535649-Jan-05 15:45 
QuestionWindows Forms question: How to lock scrollbars? Pin
kmansari7-Jan-05 14:33
kmansari7-Jan-05 14:33 
GeneralWeb-Services with a Collection of a custom object Pin
He11razor7-Jan-05 13:54
He11razor7-Jan-05 13:54 
GeneralRe: Web-Services with a Collection of a custom object Pin
Andy Brummer7-Jan-05 17:18
sitebuilderAndy Brummer7-Jan-05 17:18 
Generalwindows socket Pin
WaleedH7-Jan-05 11:16
WaleedH7-Jan-05 11:16 
GeneralRe: windows socket Pin
Alex Korchemniy7-Jan-05 11:26
Alex Korchemniy7-Jan-05 11:26 
GeneralRe: windows socket Pin
kmansari7-Jan-05 14:30
kmansari7-Jan-05 14:30 
Generalwindows socket Pin
ghjhgjghjghj7-Jan-05 11:16
sussghjhgjghjghj7-Jan-05 11:16 
GeneralRe: windows socket Pin
MoustafaS8-Jan-05 1:17
MoustafaS8-Jan-05 1:17 
GeneralRe: windows socket Pin
Alex Korchemniy8-Jan-05 5:37
Alex Korchemniy8-Jan-05 5:37 
GeneralPowerPoint automation question Pin
Asad Hussain7-Jan-05 11:00
Asad Hussain7-Jan-05 11:00 
GeneralRe: PowerPoint automation question Pin
Alex Korchemniy7-Jan-05 11:12
Alex Korchemniy7-Jan-05 11:12 
Questionpressure clock ?? Pin
Sakkijha7-Jan-05 10:46
Sakkijha7-Jan-05 10:46 
AnswerRe: pressure clock ?? Pin
Alex Korchemniy7-Jan-05 11:18
Alex Korchemniy7-Jan-05 11:18 
GeneralRe: pressure clock ?? Pin
Sakkijha8-Jan-05 4:47
Sakkijha8-Jan-05 4:47 
GeneralRe: pressure clock ?? Pin
Alex Korchemniy8-Jan-05 5:33
Alex Korchemniy8-Jan-05 5:33 
Generalservices and WaitForStatus Pin
sprout747-Jan-05 10:36
sprout747-Jan-05 10:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.