コード例 #1
0
ファイル: RecieverMain.cs プロジェクト: NicoBarbaros/PADLabs
        static void Main(string[] args)
        {
            AoInterface receiverNetwork = new Network(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 15000));
            AoInterface receiverFile = new FileSystemDLL("output.xml");
            Console.WriteLine("Do you want to subscribe? (Y/N)");
            string n = Console.ReadLine();
            if (n.Equals("Y"))
            {
                receiverNetwork.WriteAsync("subscriber");
            }

            else
            {
                Console.WriteLine("Thank you. You can press enter to exit");
                Console.ReadKey();
                System.Environment.Exit(1);
            }

            Task t = Task.Factory.StartNew(
                async () =>
                {
                    string m;
                    Console.ReadKey();

                    while ((m = await receiverNetwork.ReadAsync()) != "1")
                    {
                        Console.WriteLine(m);
                        receiverFile.WriteAsync(m);
                    }
                });

            t.Wait();
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Print();

            ////sender
            AoInterface fileObj = new FileSystemDLL("test.xml");

            ////// serialization of XML file
            Task<string> dataReturns = fileObj.ReadAsync();
            AoInterface networkObj = new Network(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 15000));

            Task t = Task.Factory.StartNew(
                 () =>
                 {
                    networkObj.WriteAsync(dataReturns.Result);
                    Console.WriteLine("Message Sent");
                 });

            t.Wait();
            Console.ReadLine();
        }