[英]I can't communicate between UWP app and Win32 app
Program.cs程序.cs
using System;
using System.IO.MemoryMappedFiles;
using Windows.Storage;
using System.Threading;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace XBOXGameBarPoC_Win32
{
static class Program
{
static void Main()
{
while (true)
{
using (var file = MemoryMappedFile.OpenExisting("XboxGameBarPoc_SharedMemory"))
{
using (var writer = file.CreateViewAccessor(0, 10))
{
writer.Write(0, 500);
}
}
}
}
}
}
MainPage.xaml.cs MainPage.xaml.cs
using System.IO.MemoryMappedFiles;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using System.Threading;
using Microsoft.Graphics.Canvas;
using Windows.UI;
using Windows.UI.Popups;
using System;
namespace XBOXGameBarPoC_UWP
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
MemoryMappedFile.CreateOrOpen("XboxGameBarPoc_SharedMemory", 0x644, MemoryMappedFileAccess.ReadWriteExecute);
}
private void canvasSwapChainPanel_Loaded(object sender, RoutedEventArgs e)
{
CanvasDevice device = CanvasDevice.GetSharedDevice();
canvasSwapChainPanel.SwapChain = new CanvasSwapChain(device, (float)Window.Current.CoreWindow.Bounds.Width, (float)Window.Current.CoreWindow.Bounds.Height, 96);
Thread renderThread = new Thread(new ParameterizedThreadStart(RenderThread));
renderThread.Start(canvasSwapChainPanel.SwapChain);
}
private void RenderThread(object parameter)
{
CanvasSwapChain swapChain = (CanvasSwapChain)parameter;
using (MemoryMappedFile memoryMappedFile = MemoryMappedFile.OpenExisting("XboxGameBarPoc_SharedMemory"))
{
using (MemoryMappedViewAccessor viewAccessor = memoryMappedFile.CreateViewAccessor())
{
System.Numerics.Vector2 CenterTop;
CenterTop.X = 1920 / 2.0f;
CenterTop.Y = 0.0f;
int count = 0;
while (true)
{
using (CanvasDrawingSession ds = canvasSwapChainPanel.SwapChain.CreateDrawingSession(Colors.Transparent))
{
viewAccessor.Read<int>(0, out count);
ds.DrawRectangle(count, 300, 150, 100, Colors.Red, 5);
canvasSwapChainPanel.SwapChain.Present();
}
}
}
}
}
struct Box
{
public float X;
public float Y;
public float Width;
public float Height;
}
}
}
This issue is really killed my entire motivation.这个问题真的扼杀了我的全部动力。 Nothing happens with those codes.这些代码没有任何反应。 I'm trying to communicate between Win32-UWP application.我正在尝试在 Win32-UWP 应用程序之间进行通信。 Win32 will constantly send information and UWP will draw based on that info. Win32 将不断发送信息,UWP 将根据该信息绘制。 I tried almost everything, but still failing.我几乎尝试了一切,但仍然失败。 I can attach project aswell if it's required.如果需要,我也可以附加项目。
I can't communicate between UWP app and Win32 app我无法在 UWP 应用程序和 Win32 应用程序之间通信
MemoryMappedFile
is not compatible with UWP platform. MemoryMappedFile
与 UWP 平台不兼容。 For Interprocess communication we suggest you use App services or Loopback here is official document that you could refer to.对于进程间通信,我们建议您使用应用服务或环回这里是官方文档,您可以参考。
I found you were using shared Memory to Interprocess communicate please refer this sharing named objects that could available in UWP platform.我发现您正在使用共享 Memory 进行进程间通信,请参阅此共享命名对象,该对象可在 UWP 平台中使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.