當前位置: 首頁>>代碼示例>>C#>>正文


C# NamedPipeServerStream.EndWrite方法代碼示例

本文整理匯總了C#中System.IO.Pipes.NamedPipeServerStream.EndWrite方法的典型用法代碼示例。如果您正苦於以下問題:C# NamedPipeServerStream.EndWrite方法的具體用法?C# NamedPipeServerStream.EndWrite怎麽用?C# NamedPipeServerStream.EndWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.Pipes.NamedPipeServerStream的用法示例。


在下文中一共展示了NamedPipeServerStream.EndWrite方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PipeServerAsyncEnumerator

		private static IEnumerator<Int32> PipeServerAsyncEnumerator(AsyncEnumerator ae) {
			// Each server object performs asynchronous operation on this pipe
			using (var pipe = new NamedPipeServerStream(
				"Echo", PipeDirection.InOut, -1, PipeTransmissionMode.Message,
				PipeOptions.Asynchronous | PipeOptions.WriteThrough)) {
				// Asynchronously accept a client connection
				pipe.BeginWaitForConnection(ae.End(), null);
				yield return 1;

				// A client connected, let's accept another client
				var aeNewClient = new AsyncEnumerator();
				aeNewClient.BeginExecute(PipeServerAsyncEnumerator(aeNewClient),
					aeNewClient.EndExecute);

				// Accept the client connection
				pipe.EndWaitForConnection(ae.DequeueAsyncResult());

				// Asynchronously read a request from the client
				Byte[] data = new Byte[1000];
				pipe.BeginRead(data, 0, data.Length, ae.End(), null);
				yield return 1;

				// The client sent us a request, process it
				Int32 bytesRead = pipe.EndRead(ae.DequeueAsyncResult());

				// Just change to upper case
				data = Encoding.UTF8.GetBytes(
					Encoding.UTF8.GetString(data, 0, bytesRead).ToUpper().ToCharArray());

				// Asynchronously send the response back to the client
				pipe.BeginWrite(data, 0, data.Length, ae.End(), null);
				yield return 1;

				// The response was sent to the client, close our side of the connection
				pipe.EndWrite(ae.DequeueAsyncResult());
			} // Close happens in a finally block now!
		}
開發者ID:Helen1987,項目名稱:edu,代碼行數:37,代碼來源:PipeServerLib.cs

示例2: BeginWriteCallback

 private void BeginWriteCallback(IAsyncResult iar)
 {
     pipeServer = (NamedPipeServerStream)iar.AsyncState;
     pipeServer.EndWrite(iar);
     sendRequested = false;
     pipeServer.Flush();
 }
開發者ID:hkgsherlock,項目名稱:hkhr-atp2,代碼行數:7,代碼來源:AsyncPipeServer.cs


注:本文中的System.IO.Pipes.NamedPipeServerStream.EndWrite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。