コード例 #1
0
        public static void runServer()
        {
            Socket         connection;
            ThreadingClass threader;

            try
            {
                //wating for someone to connect and accept the connection
                int port = 43;
                listener = new TcpListener(IPAddress.Any, port); //initialising the listener to listen for any IP adress coming through port 43, pointing the listener in the right direction
                listener.Start();                                //starts the listening
                Console.WriteLine("Server started listening");
                while (true)
                {
                    //this establishes the connection from the client to the server
                    //wating for someone to connect and accept the connection
                    connection = listener.AcceptSocket();                                       //socket interface accepts the incoming data

                    threader = new ThreadingClass();
                    Thread thread = new Thread(() => threader.doRequest(connection));
                    thread.Start();


                    //allows for the stream of data for the network access
                    //socket interface closes the connection
                    Console.WriteLine("Connection Established\r\n");
                }
            }
            catch (Exception e)
            {
                // class for a login function
                Console.WriteLine("Exception: " + e);
            }
        }
コード例 #2
0
    static void Main(string[] args)
    {
        ThreadingClass th      = new ThreadingClass();
        Thread         thread1 = new Thread(th.DoStuff);

        thread1.Start();
        Console.WriteLine("Press any key to exit!!!");
        Console.ReadKey();
        th.Stop();
        thread1.Join();
    }
コード例 #3
0
ファイル: Program.cs プロジェクト: dealen/70-483
        public static void SimpleThreads()
        {
            IRun tc = new ThreadingClass();
            //tc.ThreadMethod();

            IRun st = new StopingThread();
            //st.Run();

            IRun tsat = new ThreadStaticAttributeTest();
            //tsat.Run();

            IRun tld = new ThreadLocalData();

            tld.Run();

            IRun tpt = new ThreadPoolTests();

            tpt.Run();
        }