4 changed files with 73 additions and 19 deletions
@ -0,0 +1,53 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.IO.MemoryMappedFiles; |
|||
using System.IO.Pipes; |
|||
using System.Text; |
|||
using System.Windows; |
|||
|
|||
namespace Utils |
|||
{ |
|||
public class MemoryHelper |
|||
{ |
|||
/// <summary>
|
|||
/// 获取token
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public static string GetMemoryToken() |
|||
{ |
|||
try |
|||
{ |
|||
string pipeId = Environment.GetCommandLineArgs()[1]; |
|||
//创建输入类型匿名管道
|
|||
using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipeId)) |
|||
{ |
|||
using (StreamReader sr = new StreamReader(pipeClient)) |
|||
{ |
|||
string temp; |
|||
|
|||
do |
|||
{ |
|||
temp = sr.ReadLine(); |
|||
} |
|||
while (!temp.StartsWith("SYNC")); |
|||
|
|||
|
|||
while ((temp = sr.ReadLine()) != null) |
|||
{ |
|||
return temp; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return string.Empty; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
return string.Empty; |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue