예제 #1
0
파일: Host.cs 프로젝트: user135711/qmlnet
        public static int Run(string[] args, Func <string[], QGuiApplication, QQmlApplicationEngine, NetRunCallbackDelegate, int> action)
        {
            if (args.Length < 4)
            {
                throw new Exception("Args is invalid, must contain three entries which are pointers to native types.");
            }

            var appPtr            = new IntPtr((long)ulong.Parse(args[0]));
            var enginePtr         = new IntPtr((long)ulong.Parse(args[1]));
            var callbackPtr       = new IntPtr((long)ulong.Parse(args[2]));
            var exportedSymbolPtr = new IntPtr((long)ulong.Parse(args[3]));

            GetExportedSymbol = Marshal.GetDelegateForFunctionPointer <GetExportedSymbolDelegate>(exportedSymbolPtr);

            using (var app = new QGuiApplication(appPtr))
            {
                using (var engine = new QQmlApplicationEngine(enginePtr))
                {
                    var runCallback = new NetRunCallbackDelegate(() =>
                    {
                        var callback = Marshal.GetDelegateForFunctionPointer <NativeRunCallbackDelegate>(callbackPtr);
                        // ReSharper disable AccessToDisposedClosure
                        return(callback.Invoke(app.InternalPointer, engine.InternalPointer));
                        // ReSharper restore AccessToDisposedClosure
                    });
                    return(action(args.Skip(2).ToArray(), app, engine, runCallback));
                }
            }
        }
예제 #2
0
 public QtSynchronizationContext(QGuiApplication guiApp)
 {
     _guiApp = guiApp;
 }