initial commit
This commit is contained in:
40
Handler/Sub/MemoryMapCore/Server.cs
Normal file
40
Handler/Sub/MemoryMapCore/Server.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.MemoryMappedFiles;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace AR.MemoryMap
|
||||
{
|
||||
public class Server : Core
|
||||
{
|
||||
public Server(string MapFileName, int MapFileSize, int loopDelay = 50) : base(MapFileName, MapFileSize, loopDelay)
|
||||
{
|
||||
StartAction = () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var MapFileSync = $"{MapFileName}{MapFileSize}";
|
||||
mmf = MemoryMappedFile.CreateOrOpen(MapFileName, MapFileSize);
|
||||
mutex = new Mutex(false, MapFileSync, out mutexCreated);
|
||||
ErrorMessage = string.Empty;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
StopAction = () =>
|
||||
{
|
||||
ErrorMessage = string.Empty;
|
||||
brun = false;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user