Esempio n. 1
0
        public void Pipe_Reader(NamedPipeServerStream server)
        {
            //int i = 0;

            var br  = new BinaryReader(server);
            var str = "";

            while (true)
            {
                try
                {
                    //i++;
                    var len = (int)br.ReadUInt32();
                    if (len == 0)
                    {
                        str = new string(br.ReadChars(len)); // Read string
                    }
                    if (str == "OK")
                    {
                        if (this.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker) delegate
                            {
                                Close_Current_Form ccf = new Close_Current_Form(this.Close);
                                this.Invoke(ccf);
                            });
                            break;
                        }
                    }

                    else
                    {
                        if (this.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker) delegate
                            {
                                MessageBox.Show("NOTOK");
                            });

                            this.Invoke((MethodInvoker) delegate
                            {
                                MessageBox.Show("Wrong User Name Or Password");
                                KBF_Activation_Delegate KBF = new KBF_Activation_Delegate(this.KBF_Activation);
                                this.Invoke(KBF);
                            });
                            break;
                        }
                    }
                }

                catch
                {
                    //MessageBox.Show("Error");
                }
            }

            //Pipe_Writer(server);
        }
Esempio n. 2
0
        public void Pipe_Reader(NamedPipeServerStream server)
        {
            //int i = 0;

            var br = new BinaryReader(server);

            while (true)
            {
                try
                {
                    //i++;
                    var len = (int)br.ReadUInt32();
                    if (len == 0)
                        MessageBox.Show("len equals zero");

                    var str = new string(br.ReadChars(len));    // Read string
                    if (str == "OK")
                    {
                        if (this.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker)delegate
                            {
                                Close_Current_Form ccf = new Close_Current_Form(this.Close);
                                this.Invoke(ccf);
                            });
                            break;
                        }
                    }

                    else
                    {

                        if (this.InvokeRequired)
                        {

                            this.Invoke((MethodInvoker)delegate
                            {
                                MessageBox.Show("Wrong User Name Or Password");
                                KBF_Activation_Delegate KBF = new KBF_Activation_Delegate(this.KBF_Activation);
                                this.Invoke(KBF);

                            });
                            break;
                        }

                    }
                }

                catch
                {
                    //MessageBox.Show("Error");
                }

            }

            //Pipe_Writer(server);
        }