41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
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;
|
|
};
|
|
}
|
|
}
|
|
}
|