本文整理汇总了C#中Pipe.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Pipe.Close方法的具体用法?C# Pipe.Close怎么用?C# Pipe.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pipe
的用法示例。
在下文中一共展示了Pipe.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static int Main(string[] args)
{
args.Switches();
ErrCount = 0;
if (args.SwitchValue("help") != null)
{
Console.Out.WriteLine(HelpMessage);
return -1;
}
if (args.SwitchValue("timeout") != null)
if (!(Int32.TryParse(args.SwitchValue("timeout"), out Timeout)))
Timeout = DefaultTimeout;
string sysfeed = args.SwitchValue("sysfeed");
string sesfeed = args.SwitchValue("sesfeed");
string pack = args.SwitchValue("package");
if (args.SwitchValue("ansi") != null)
ANSI = true;
if (sysfeed == null || sesfeed == null || pack == null)
{
Console.Out.WriteLine(HelpMessage);
return -1;
}
asyncServer = new Pipe(new NamedPipeClientStream(ServerName, PipeName, PipeDirection.InOut, PipeOptions.Asynchronous, TokenImpersonationLevel.Impersonation, HandleInheritability.Inheritable));
//asyncServer = new Pipe(new NamedPipeClientStream(PipeName));
if (Connect().Passed)
{
// Add Async tests here
Output(AddSystemFeed(sysfeed));
Output(AddSessionFeed(sesfeed));
Output(FindFeeds());
Output(FindPackage_Failure());
UrlEncodedMessage LocalPackage, FeedPackage;
Output(RecognizeFile(pack));
Output(FindAllPackages());
string LocalName = pack.Substring(pack.LastIndexOf(@"\") + 1);
LocalName = LocalName.Substring(0, LocalName.LastIndexOf('.')); //strip ".msi" from the end
Output(FindFirstPackageByName(LocalName, out LocalPackage));
Output(FindFirstUninstalledPackage(out FeedPackage));
Output(VerifySig(pack));
Output(VerifySig(pack,true));
Output(UnableToAcquire());
string LocalPackageCName = "LocalPackage_Failed_To_Be_Found";
string FeedPackageCName = "FeedPackage_Failed_To_Be_Found";
if (LocalPackage != null)
LocalPackageCName = LocalPackage["canonical-name"];
if (FeedPackage != null)
FeedPackageCName = FeedPackage["canonical-name"];
Output(PackageDetails(FeedPackageCName));
Output(InstallImmaginaryPackage());
Output(InstallLocalPackage(LocalPackageCName));
Output(SetPackageAttribs(LocalPackageCName,null,null,false));
Output(RemovePackage(LocalPackageCName));
Output(RemoveSessionFeed(sesfeed));
Output(RemoveSystemFeed(sysfeed));
asyncServer.Close();
}
return ErrCount;
}
示例2: Stress
public void Stress(string name)
{
for (int j = 0; j < 10; j++) {
int times = 10;
int close_cb_called = 0;
int cl_send_cb_called = 0;
int cl_recv_cb_called = 0;
int sv_send_cb_called = 0;
int sv_recv_cb_called = 0;
var server = new PipeListener();
server.Bind(name);
server.Connection += () => {
var pipe = server.Accept();
pipe.Resume();
pipe.Read(Encoding.ASCII, (str) => {
sv_recv_cb_called++;
Assert.AreEqual(Times("PING", times), str);
for (int i = 0; i < times; i++) {
pipe.Write(Encoding.ASCII, "PONG", (s) => { sv_send_cb_called++; });
}
pipe.Close(() => { close_cb_called++; });
server.Close(() => { close_cb_called++; });
});
};
server.Listen();
Pipe client = new Pipe();
client.Connect(name, (_) => {
client.Resume();
for (int i = 0; i < times; i++) {
client.Write(Encoding.ASCII, "PING", (s) => { cl_send_cb_called++; });
}
client.Read(Encoding.ASCII, (str) => {
cl_recv_cb_called++;
Assert.AreEqual(Times("PONG", times), str);
client.Close(() => { close_cb_called++; });
});
});
Assert.AreEqual(0, close_cb_called);
Assert.AreEqual(0, cl_send_cb_called);
Assert.AreEqual(0, cl_recv_cb_called);
Assert.AreEqual(0, sv_send_cb_called);
Assert.AreEqual(0, sv_recv_cb_called);
Loop.Default.Run();
Assert.AreEqual(3, close_cb_called);
Assert.AreEqual(times, cl_send_cb_called);
Assert.AreEqual(1, cl_recv_cb_called);
Assert.AreEqual(times, sv_send_cb_called);
Assert.AreEqual(1, sv_recv_cb_called);
#if DEBUG
Assert.AreEqual(1, UV.PointerCount);
#endif
}
}
示例3: Simple
public static void Simple(string name)
{
int close_cb_called = 0;
int cl_send_cb_called = 0;
int cl_recv_cb_called = 0;
int sv_send_cb_called = 0;
int sv_recv_cb_called = 0;
var server = new PipeListener();
server.Bind(name);
server.IncommingStream += () => {
var pipe = server.AcceptStream();
pipe.Resume();
pipe.Read(Encoding.ASCII, (str) => {
sv_recv_cb_called++;
Assert.AreEqual("PING", str);
pipe.Write(Encoding.ASCII, "PONG", (s) => { sv_send_cb_called++; });
pipe.Close(() => { close_cb_called++; });
server.Close(() => { close_cb_called++; });
});
};
server.Listen();
Pipe client = new Pipe();
client.Connect(name, (_) => {
client.Resume();
client.Write(Encoding.ASCII, "PING", (s) => { cl_send_cb_called++; });
client.Read(Encoding.ASCII, (str) => {
cl_recv_cb_called++;
Assert.AreEqual("PONG", str);
client.Close(() => { close_cb_called++; });
});
});
Assert.AreEqual(0, close_cb_called);
Assert.AreEqual(0, cl_send_cb_called);
Assert.AreEqual(0, cl_recv_cb_called);
Assert.AreEqual(0, sv_send_cb_called);
Assert.AreEqual(0, sv_recv_cb_called);
Loop.Default.Run();
Assert.AreEqual(3, close_cb_called);
Assert.AreEqual(1, cl_send_cb_called);
Assert.AreEqual(1, cl_recv_cb_called);
Assert.AreEqual(1, sv_send_cb_called);
Assert.AreEqual(1, sv_recv_cb_called);
#if DEBUG
Assert.AreEqual(1, UV.PointerCount);
#endif
}