BolterLibrary.InterProcessCom.PassInfo C# (CSharp) Method

PassInfo() public static method

Function that starts Bolter. Takes various information that the unmanaged side needs to pass to the managed side.
public static PassInfo ( string configPath, int fPtrs ) : int
configPath string
fPtrs int
return int
        public static int PassInfo(string[] configPath, int[] fPtrs)
        {
            Console.Write(configPath[0]);
            EventWaitHandle result;
            EventWaitHandle.TryOpenExisting(@"Global\FinishedLoading",
                EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify, out result);
            if (result != null)
            {
                eHandle = result;
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

            ConfigPath = Path.GetDirectoryName(Path.GetDirectoryName(configPath[0])) + "\\Resources";

            var count = 0;
            foreach (var f in typeof(Funcs).GetFields())
            {
                f.SetValue(null, Marshal.GetDelegateForFunctionPointer((IntPtr)fPtrs[count], f.FieldType));
                count++;
            }

            new Thread(new ThreadStart(delegate
            {
                pHandle =
                    AppDomain.CurrentDomain.GetAssemblies()
                        .First(ass => ass.GetTypes().Any((t => t.Name == "PluginMain")))
                        .GetTypes().First(t => t.Name == "PluginMain")
                        .GetConstructors()
                        .First()
                        .Invoke(null);
                pHandle.GetType().GetMethod("Start").Invoke(pHandle, null);
            })) { ApartmentState = ApartmentState.STA }.Start();
            return 1;
        }