适配跨平台,winform乱码

This commit is contained in:
snltty
2023-11-29 17:40:41 +08:00
parent 1f0bfa6dc6
commit 26430402c4
3 changed files with 13 additions and 5 deletions

View File

@@ -57,7 +57,7 @@ namespace cmonitor.libs
{
if (OperatingSystem.IsWindows() && accessorGlobal == null)
{
accessorGlobal = ShareMemoryFactory.Create(key, length, itemSize);
accessorGlobal = ShareMemoryFactory.Create($"Global\\{key}", length, itemSize);
if (accessorGlobal.Init() == false)
{
accessorGlobal = null;
@@ -168,11 +168,16 @@ namespace cmonitor.libs
lock (lockObj)
{
accessorLocal.ReadArray(0, bytes, 0, bytes.Length);
for (int index = 0; index < length; index++)
{
//state
bool _updated = ReadState(accessorLocal, index, ShareMemoryState.Updated);
if (_updated == false) continue;
if (_updated == false)
{
continue;
}
WriteState(accessorLocal, index, ShareMemoryState.Updated, false);
updated |= _updated;

View File

@@ -3,7 +3,6 @@ using System.Diagnostics;
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Text;
using System.Text.Json;
namespace cmonitor.sas.service
{
@@ -102,7 +101,7 @@ namespace cmonitor.sas.service
}
}, cancellationTokenSource, TaskCreationOptions.LongRunning);
}
private void WriteAllCloseState(bool state)
{
for (int i = 0; i < shareMLength; i++)
@@ -110,7 +109,7 @@ namespace cmonitor.sas.service
shareMemory.WriteClosed(i, state);
}
}
Process proc;
private void CheckMainProcess()
{

View File

@@ -1,4 +1,5 @@
using cmonitor.libs;
using common.libs.extends;
using MemoryPack;
namespace cmonitor.server.client.reports.share
@@ -47,7 +48,10 @@ namespace cmonitor.server.client.reports.share
if (OperatingSystem.IsWindows())
{
if (shareMemory != null)
{
dic = shareMemory.GetItems(out updated);
}
}
}
catch (Exception)