当前位置: 首页>>代码示例>>C#>>正文


C# NamedPipeServerStream.CopyTo方法代码示例

本文整理汇总了C#中System.IO.Pipes.NamedPipeServerStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# NamedPipeServerStream.CopyTo方法的具体用法?C# NamedPipeServerStream.CopyTo怎么用?C# NamedPipeServerStream.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Pipes.NamedPipeServerStream的用法示例。


在下文中一共展示了NamedPipeServerStream.CopyTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Get

		public void Get(Stream s)
		{
			if (thr != null)
				throw new InvalidOperationException("Can only serve one thing at a time!");
			if (e != null)
				throw new InvalidOperationException("Previous attempt failed!", e);
			if (!s.CanWrite)
				throw new ArgumentException("Stream must be readable!");

			using (var evt = new ManualResetEventSlim())
			{
				thr = new Thread(delegate()
					{
						try
						{
							using (var srv = new NamedPipeServerStream(PipeName, PipeDirection.In))
							{
								evt.Set();
								srv.WaitForConnection();
								srv.CopyTo(s);
								//srv.Flush();
							}
						}
						catch (Exception ee)
						{
							e = ee;
						}
					});
				thr.Start();
				evt.Wait();
			}
		}
开发者ID:ddugovic,项目名称:RASuite,代码行数:32,代码来源:FilePiping.cs

示例2: ProcessMessages

        public bool ProcessMessages(NamedPipeServerStream server)
        {
            try
            {
                BinaryFormatter binForm = new BinaryFormatter();
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    server.CopyTo(memoryStream);
                    memoryStream.Seek(0, SeekOrigin.Begin);
                    object data = binForm.Deserialize(memoryStream);
                    Application.Current.Dispatcher.InvokeAsync(() =>
                    {
                        string message = data as string;
                        if (message != null)
                        {
                            switch (message)
                            {
                                case "MainWindow":
                                    {

                                        foreach (Window win in Application.Current.Windows)
                                        {
                                            if (win.GetType() == typeof(MainWindow))
                                            {
                                                win.Activate();
                                                return;
                                            }
                                        }
                                        MainWindow mw = new MainWindow();
                                        mw.Show();
                                        mw.Activate();
                                        break;
                                    }
                                case "Exit":
                                    {
                                        Application.Current.Shutdown();
                                        break;
                                    }
                            }
                        }
                        else
                        {
                            var newGesture = data as Tuple<string, List<List<List<Point>>>>;
                            if (newGesture == null) return;

                            GestureDefinition gu = new GestureDefinition(new Gesture(newGesture.Item1, newGesture.Item2.Select(list => new PointPattern(list)).ToArray()), false);
                            gu.Show();
                            gu.Activate();
                        }
                    }, DispatcherPriority.Input);
                }
                return true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }
        }
开发者ID:YashMaster,项目名称:GestureSign,代码行数:59,代码来源:MessageProcessor.cs

示例3: ReadThreadStart

        private void ReadThreadStart(NamedPipeServerStream decodePipe, Process encoder)
        {
            const int bufSize = 5 * 1024 * 1024;
            byte[] buffer = new byte[bufSize];

            if (!decodePipe.IsConnected)
                decodePipe.WaitForConnection();

            try
            {
                decodePipe.CopyTo(encoder.StandardInput.BaseStream);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            encoder.StandardInput.BaseStream.Close();
        }
开发者ID:jesszgc,项目名称:VideoConvert,代码行数:19,代码来源:X264.cs

示例4: RunAsync

        public async Task<Stream> RunAsync(Stream output, string query, params string[] sqlArguments)
        {
            NamedPipeServerStream pipeServerStream = new NamedPipeServerStream("SqlBcpWrapper" + GetHashCode(), PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous);

            pipeServerStream.BeginWaitForConnection(e =>
            {
                pipeServerStream.EndWaitForConnection(e);

                while (pipeServerStream.IsConnected && !pipeServerStream.IsMessageComplete)
                {
                }

                pipeServerStream.CopyTo(output);
                output.Seek(0, SeekOrigin.Begin);
                pipeServerStream.Disconnect();
                pipeServerStream.Close();
            }, this);
            
            RunInternal("\\\\.\\pipe\\SqlBcpWrapper" + GetHashCode(), query, sqlArguments, null, null);

            await Task.Run(() =>
            {
                while (pipeServerStream.IsConnected && !pipeServerStream.IsMessageComplete)
                {
                }
            });

            return output;
        }
开发者ID:sbruyere,项目名称:SqlBcpWrapper,代码行数:29,代码来源:SqlBcpWrapper.cs


注:本文中的System.IO.Pipes.NamedPipeServerStream.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。