2017-04-12 9 views
0

내 프로그램 (아래)은 Fedora 22에서 작동하거나 main()에서 스레드 함수를 직접 호출하면 작동합니다. 하지만 우분투 16.04의 스레드에서 모노 호출을 실행하면 다음과 같이 나타납니다. 내가 뭔가 잘못하고 있는거야?우분투 스레드에서 모노 크래시

하워드 루빈

출력 :

$ rm monotest.dll ; make ; ./monotest 
Mono C# compiler version 4.8.0.0 
mcs monotest.cs /out:monotest.dll /target:library 
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 
g++ monotest.cpp -o monotest -g3 -std=c++11 `pkg-config --cflags --libs mono-2` 
* Assertion at mono-threads-posix.c:265, condition `info->handle' not met 

Aborted (core dumped) 
$ 

=============================== ===

// monotest.cpp 
#include <thread> 
#include <mono/jit/jit.h> 

void Thread() { 
    MonoDomain* domain = mono_jit_init("monotest.dll"); 
    mono_jit_cleanup(domain); 
} 

int main() { 
    //Thread(); 
    std::thread t(Thread); 
    t.join(); 
} 

==================================

//////////////////////// 
// monotest.cs 
namespace MyNamespace { 

    public class MyClass { 
     public MyClass() { } 

     public void MySum(int arg1, int arg2) { 
      System.Console.WriteLine("MySum(" + arg1 + "," + arg2 + ") => " + (arg1 + arg2)); 
     } 
    } 
} 

================= =================

################### 
# Makefile 
monotest : monotest.cpp monotest.dll Makefile 
     @g++ --version | head -1 
     g++ $< -o [email protected] -g3 -std=c++11 `pkg-config --cflags --libs mono-2` 

monotest.dll : monotest.cs 
     @mcs --version 
     mcs $< /out:[email protected] /target:library 

답변

0

모노 스레드를 사용하는 문서는 비참하게 부적당하지만, 실험 스레드와 함께 작동하도록 만들 수 있습니다.

한 가지 방법은 mono_thread_create()를 사용하는 것입니다.

또 다른 하나는 스레드 외부에서 mono_jit_init()를 열고, 생성 된 스레드에서 처음에는 mono_thead_attach()를 호출하고 마지막에는 mono_thread_detach()를 호출하는 것입니다.