public void Execute(string arguments) { ProcessStartInfo processStartInfo = new ProcessStartInfo { FileName = "git", UseShellExecute = false, WorkingDirectory = path, Arguments = arguments, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }; Process process = Process.Start(processStartInfo); process.OutputDataReceived += (object sender, DataReceivedEventArgs e) => { if (e.Data != null) { OnDataArrived?.Invoke(new RepositoryEventArgs(e.Data, arguments, RepositoryEventArgs.StatusType.Normal)); } }; process.BeginOutputReadLine(); process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => { if (e.Data != null) { OnDataArrived?.Invoke(new RepositoryEventArgs(e.Data, arguments, RepositoryEventArgs.StatusType.Error)); } }; process.BeginErrorReadLine(); process.WaitForExit(); }
internal void UDPReciever() { try { timerforchecklogin = new System.Timers.Timer(); timerforchecklogin.Interval = 30000; timerforchecklogin.Start(); timerforchecklogin.Elapsed += timerforchecklogin_Elapsed; Task.Factory.StartNew(() => { while (true) { // string address = subscriber.Receive (Encoding.Unicode); // byte[] buffer = new byte[512]; // int bufferSize = subscriber.Receive (buffer); var buffer = subscriber.Receive(); if (buffer == null) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("STOP")); continue; } FinalPrice _obj = (FinalPrice)DataPacket.RawDeserialize(buffer.Skip(4).Take(buffer.Length - 4).ToArray(), typeof(FinalPrice)); // Console.WriteLine("Received"); // if(_obj.Token==37454) // Console.Title="Token: "+_obj.Token+", Bid: "+_obj.MAXBID+", Ask: "+_obj.MINASK+" LTP: "+_obj.LTP; // else// if (_obj.Token==66039) // Console.WriteLine("Token {0} Bid {1} Ask {2} LTP {3}",_obj.Token,_obj.MAXBID,_obj.MINASK,_obj.LTP); if (_obj.Token == 111) { Console.WriteLine(" SomeThing Wrong in DATA Server"); this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("START")); // OnDataError.Invoke(); continue; } if (_iSubscribe.Contains(_obj.Token)) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("START")); OnDataArrived.Raise(OnDataArrived, OnDataArrived.CreateReadOnlyArgs(_obj)); } } }); } catch (OperationCanceledException e) { Console.WriteLine("Cancellation invoked"); } catch (AggregateException e) { Console.WriteLine("Some unexpected exception "); } catch (Exception Ex) { Console.WriteLine("Exception Raised " + Ex.StackTrace); } }
private void OnTimer(object state) { int bytesCount = _random.Next(1, 10); byte[] buf = new byte[bytesCount]; _dataFileStream.Read(buf, 0, bytesCount); OnDataArrived?.Invoke(this, new PortEventArgs(Encoding.UTF8.GetString(buf))); }
private void Read() { try { byte[] buffer = new byte[_client.ReceiveBufferSize]; _nwStream.Read(buffer, 0, _client.ReceiveBufferSize); OnDataArrived?.Invoke(buffer); } catch (Exception) { // do nothing. it's okay, we still love you. } }
private void invokeDataArrived(StspOperation option, IBufferPacket data) { OnDataArrived?.Invoke(option, data); }
internal void UDPReciever(String LanIP = "127.0.0.1", string McastIp = "226.1.1.1" /* "239.70.70.21"*/, int port = 5050) //10821) // internal void UDPReciever(String LanIP = "127.0.0.1", string McastIp = "233.1.2.5", int port = 34330) { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); s.ExclusiveAddressUse = false; s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); IPEndPoint ipep = new IPEndPoint(IPAddress.Any, Convert.ToInt32(port)); s.Bind(ipep); IPAddress ip = IPAddress.Parse(McastIp); s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Parse("127.0.0.1"))); byte[] r_req = new byte[BufferSize]; try { //Task.Run(() => Task.Factory.StartNew(() => { while (!cts.IsCancellationRequested) { int size = s.Receive(r_req); if (size > 0) { FinalPrice _obj = (FinalPrice)DataPacket.RawDeserialize(r_req, typeof(FinalPrice)); //Console.WriteLine("Token {0} Bid {1} Ask {2} LTP {3}",_obj.Token,_obj.MAXBID,_obj.MINASK,_obj.LTP); if (_iSubscribe.Contains(_obj.Token)) { OnDataArrived.Raise(OnDataArrived, OnDataArrived.CreateReadOnlyArgs(_obj)); } } cts.Token.ThrowIfCancellationRequested(); } }, cts.Token); } catch (OperationCanceledException) { Console.WriteLine("Cancellation invoked"); } catch (AggregateException e) { if (e.InnerException is OperationCanceledException) { if (s != null) { if (s.Connected) { s.Shutdown(SocketShutdown.Both); s.Close(); } } } else { Console.WriteLine("Some unexpected exception "); } } catch (Exception Ex) { Console.WriteLine("Exception Raised " + Ex.Message); } }