English 中文(简体)
Mon_delegate_to_ftnptr: function calls onhangs
原标题:mono_delegate_to_ftnptr: function call hangs

I m 将单一2.10.8插入我的申请,并有一些职能方面的麻烦,登记在mono_add_internal_quest/code>。

Let s say i have managed method:

internal delegate void Win32ServiceHandler(long statusCode);

internal static class Win32Service
{
  [MethodImpl(MethodImplOptions.InternalCall)]
  public static extern void Test(Win32ServiceHandler handler);
}

其定义未经管理:

void icall_TestDelegateCallback(MonoDelegate *ftn) {
  LPHANDLER_FUNCTION f = (LPHANDLER_FUNCTION)mono_delegate_to_ftnptr(ftn);
  f(SERVICE_CONTROL_STOP);
}

以及一些测试守则:

protected virtual void ServiceHandler(Win32ServiceControl statusCode)
{   
  Console.WriteLine("here");
}

public void MakeTest()
{
  Console.WriteLine("before");
  Win32Service.Test(this.ServiceHandlerInternal);
  Console.WriteLine("after");
}

我从假释申请中管理,当我叫Make()时,产出是:

before
here

申请永远不会回来。

实际上,这是一种简化的电子实例。 在实际方案中,需要将职能点作为回击<代码> 登记册服务 如mono_runtime_invoke (每部工作罚款)等等是需要的。

The question is what is the proper way to call a function pointer obtained from MonoDelegate? Or is it any other correct way to pass it as a callback?

我的平台是Windows 7 x64

<>蓬普顿>:

有趣的调查结果。 一俟我改写成:

internal static class Win32Service
{
  [MethodImpl(MethodImplOptions.InternalCall)]
  public static extern void Test(Action handler);
}

and

typedef VOID (*TESTFTN)();

void icall_TestDelegateCallback(MonoDelegate *ftn) {
  TESTFTN f = (TESTFTN)mono_delegate_to_ftnptr(ftn);
  f();
}

并且

public void MakeTest()
{
  Console.WriteLine("before");
  Win32Service.Test(() => Console.WriteLine("here"));
  Console.WriteLine("after");
}

工作成绩斐然。 因此,问题在于将问题长期传至德国马克。 如何解决这一问题?

问题回答

DWORD是一种32个轨道分类,而C#则是一个64个轨道类型。





相关问题
What are some things Mono is not a good fit for?

I ve started your typical web project from scratch using the Mono platform. You know, web services, a UI, MySQL database, all that. I ve heard around the net that it s not a picture-perfect ...

How Reliable is Mono on Linux vs .NET on Windows?

I am trying to decide upon using Mono with C# or Python (Django) for a Linux based Web Site. My concern with C# is that Mono may not be as reliable as .NET. Does anyone have any experience with this?

System.Data in Mono

Has System.Data in Mono been expanded to include extra functionality? I m attempting to make use of the SQL Parser written for Mono in Mono.Data.SqlExpressions but when all the classes in the ...

Basic MEF workflow/usage

I m looking to a framework which will allow me to have a simple plugin system in my .NET application. It seems MEF is the framework which Microsoft is endorsing, and will become part of .NET 4 (it ...

In Mono/Gnome, how can I look up the icon for a mime type?

Gnome.Icon and Gnome.ThumbnailFactory both want me to pass in a URI of a file whose icon I want -- I only have a MIME type, which I want to look up an icon for. Is there a GNOME C# API function which ...

ASP.NET MVC 2 on mono

Is it possible to run the new ASP.NET MVC 2 Preview 2 on mono?