当前位置: 首页>>代码示例>>C#>>正文


C# AppDomain.DoCallBack方法代码示例

本文整理汇总了C#中System.AppDomain.DoCallBack方法的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.DoCallBack方法的具体用法?C# AppDomain.DoCallBack怎么用?C# AppDomain.DoCallBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.AppDomain的用法示例。


在下文中一共展示了AppDomain.DoCallBack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRemoteHost

		protected override HostedService CreateRemoteHost(AppDomain appDomain)
		{
			appDomain.SetData("ConnectionString",_connectionString);
			appDomain.DoCallBack(SetConnectionStringInAppDomain);
			var service = base.CreateRemoteHost(appDomain);
			return service;
		}
开发者ID:Teleopti,项目名称:Rhino.ServiceBus.SqlQueues,代码行数:7,代码来源:SqlRemoteAppDomainHost.cs

示例2: ConfigureNewDomain

		public void ConfigureNewDomain(AppDomain domain)
		{
			if (!string.IsNullOrWhiteSpace(AssemblyFolder))
				domain.SetData("Folder", AssemblyFolder);

			if (domain == AppDomain.CurrentDomain)
				ResolveCustomAssemblies();
			else
				domain.DoCallBack(new CrossAppDomainDelegate(ResolveCustomAssemblies));
		}
开发者ID:zhangz,项目名称:Toolbox,代码行数:10,代码来源:AppDomainCreator.cs

示例3: Load

		public static void Load(AppDomain domain, string file, Action<Assembly> callback)
		{
			Asm asm = new Asm() { asmfile = file, handler = callback };
			try
			{
				domain.DoCallBack(new CrossAppDomainDelegate(asm.loadAsmFile));
			}
			catch (Exception ex)
			{
				Console.WriteLine($"Failed to load one of the assembly into domain {domain.FriendlyName}: {ex.Message}");
			}
		}
开发者ID:mind0n,项目名称:hive,代码行数:12,代码来源:Asm.cs

示例4: ClassInitialize

		//[ClassInitialize]
		public static void ClassInitialize(TestContext context)
		{
			_serverDomain = AppDomain.CreateDomain("ServerDomain #2", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
			_serverDomain.DoCallBack(() =>
			{
				var serverChannel = new IpcServerChannel("ipc server #2", "localhost:9091", new ProtobufServerFormatterSinkProvider { FallbackToBinaryFormatter = true });
				ChannelServices.RegisterChannel(serverChannel, false);

				RemotingServices.Marshal(new TestServer(), "TestServer", typeof(ITestServer));
			});

			_clientChannel = new IpcClientChannel("ipc client #2", new BinaryClientFormatterSinkProvider());
			ChannelServices.RegisterChannel(_clientChannel, false);

			_testServer = (ITestServer)Activator.GetObject(typeof(TestServer), "ipc://localhost:9091/TestServer");
		}
开发者ID:vadimskipin,项目名称:Protobuf.Remoting,代码行数:17,代码来源:RemotingInteropTests.cs

示例5: Reload

        /// <summary>
        /// The loaded Assembly will be unloaded together with the AppDomain, when a new Assembly is loaded.
        /// Requires all used types to be Serializable.
        /// </summary>
        public void Reload()
        {
            // Requires all types to be Serializable, System.Net.Sockets.Socket is not!

            if (_appDomain != null)
            {
                AppDomain.Unload(_appDomain);
            }

            byte[] bytes = File.ReadAllBytes(_dllPath);

            _appDomain = AppDomain.CreateDomain(ASSEMBLY_NAME);
            AsmLoader asm = new AsmLoader()
            {
                Data = bytes
            };
            _appDomain.DoCallBack(asm.LoadAsm);

            AsyncSocketFactory = (IAsyncSocketFactory)asm.Assembly.CreateInstance(FULLY_QUALIFIED_TYPE_NAME);
        }
开发者ID:RasiahT,项目名称:BOD-Server,代码行数:24,代码来源:AsyncSocketModule.cs

示例6: MethodToBeRun

        private static void MethodToBeRun(AppDomain appDomain)
        {
            appDomain.DoCallBack(() =>
            {
                AppDomain myDomain = AppDomain.CurrentDomain;

                Console.WriteLine("Im in '{0}' domain", myDomain.FriendlyName);

                for (int i = 0; i < 10000000; i++)
                {
                    Console.WriteLine("Im in domain in {0}", myDomain.GetHashCode());
                }

                //Accessing outerscope varible, not possible in AppDomain, will generate error.
                // Console.WriteLine(abc);

                //For simple hang up.
                Console.ReadLine();

            }
               );
        }
开发者ID:NomadPL,项目名称:Nomad,代码行数:22,代码来源:ConsoleInjectingCodeTest.cs

示例7: FlowEnvironment

        public FlowEnvironment(string path)
        {
            File = new FileInfo(path);
            if (!File.Exists)
                throw new FileNotFoundException("Unable to find the specified file path");

            // Create a new domain
            string domainName = string.Format("FlowEnvironment.0x{0:X8}", GetHashCode());
            domain = AppDomain.CreateDomain(domainName);

            // Preload common assemblies
            domain.DoCallBack(PreloadAssemblies);

            // Load the specified flow
            Reload();

            // Watch the specified path
            watcher = new FileSystemWatcher();
            watcher.Path = File.DirectoryName;
            watcher.Filter = File.Name;
            watcher.Changed += Watcher_Changed;
            watcher.EnableRaisingEvents = true;
        }
开发者ID:jbatonnet,项目名称:flowtomator,代码行数:23,代码来源:FlowEnvironment.cs

示例8: LoadSiloInNewAppDomain

        private Silo LoadSiloInNewAppDomain(string siloName, Silo.SiloType type, ClusterConfiguration config, out AppDomain appDomain)
        {
            AppDomainSetup setup = GetAppDomainSetupInfo();

            appDomain = AppDomain.CreateDomain(siloName, null, setup);

            // Load each of the additional assemblies.
            Silo.TestHooks.CodeGeneratorOptimizer optimizer = null;
            foreach (var assembly in this.additionalAssemblies.Where(asm => asm.Value != null))
            {
                if (optimizer == null)
                {
                    optimizer =
                        (Silo.TestHooks.CodeGeneratorOptimizer)
                        appDomain.CreateInstanceFromAndUnwrap(
                            "OrleansRuntime.dll",
                            typeof(Silo.TestHooks.CodeGeneratorOptimizer).FullName,
                            false,
                            BindingFlags.Default,
                            null,
                            null,
                            CultureInfo.CurrentCulture,
                            new object[] { });
                }

                optimizer.AddCachedAssembly(assembly.Key, assembly.Value);
            }

            var args = new object[] { siloName, type, config };

            var silo = (Silo)appDomain.CreateInstanceFromAndUnwrap(
                "OrleansRuntime.dll", typeof(Silo).FullName, false,
                BindingFlags.Default, null, args, CultureInfo.CurrentCulture,
                new object[] { });

            appDomain.UnhandledException += ReportUnobservedException;
            appDomain.DoCallBack(RegisterPerfCountersTelemetryConsumer);

            return silo;
        }
开发者ID:vobradovich,项目名称:orleans,代码行数:40,代码来源:TestingSiloHost.cs

示例9: StartServers

        public static void StartServers(TestContext ctx)
        {
            #region TCP Duplex

            // Setup TCP Duplex Server AppDomain
            AppDomainSetup tcpDuplexAppDomainSetup = new AppDomainSetup() { ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) };
            _tcpDuplexServerAppDomain = AppDomain.CreateDomain("RecreateClientConnectionTests_Server", null, tcpDuplexAppDomainSetup);
            _tcpDuplexServerAppDomain.Load(typeof(ZyanConnection).Assembly.GetName());

            // Start Zyan host inside the TCP Duplex Server AppDomain
            var tcpDuplexServerWork = new CrossAppDomainDelegate(() =>
            {
                var server = TcpDuplexServerHostEnvironment.Instance;

                if (server != null)
                {
                    Console.WriteLine("TCP Duplex Server running.");
                }
            });
            _tcpDuplexServerAppDomain.DoCallBack(tcpDuplexServerWork);

            #endregion

            #region TCP Simplex

            // Setup TCP Simplex Server AppDomain
            AppDomainSetup tcpSimplexAppDomainSetup = new AppDomainSetup() { ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) };
            _tcpSimplexServerAppDomain = AppDomain.CreateDomain("RecreateClientConnectionTests_Server", null, tcpSimplexAppDomainSetup);
            _tcpSimplexServerAppDomain.Load(typeof(ZyanConnection).Assembly.GetName());

            // Start Zyan host inside the TCP Simplex Server AppDomain
            var tcpSimplexServerWork = new CrossAppDomainDelegate(() =>
            {
                var server = TcpSimplexServerHostEnvironment.Instance;

                if (server != null)
                {
                    Console.WriteLine("TCP Simplex Server running.");
                }
            });
            _tcpSimplexServerAppDomain.DoCallBack(tcpSimplexServerWork);

            #endregion
        }
开发者ID:yallie,项目名称:zyan,代码行数:44,代码来源:RecreateClientConnectionTests.cs

示例10: CreateAppDomain

        private void CreateAppDomain()
        {
            var appDomainSetup = new AppDomainSetup
            {
                ApplicationBase = applicationPath,
            };

            if (shadowCache)
            {
                appDomainSetup.ShadowCopyFiles = "true";
                appDomainSetup.CachePath = Path.Combine(applicationPath, CacheFolder);
            }

            // Create AppDomain
            appDomain = AppDomain.CreateDomain(appDomainName, AppDomain.CurrentDomain.Evidence, appDomainSetup);

            // Create appDomain Callback
            appDomainCallback = new AssemblyLoaderCallback(AssemblyLoaded, mainAssemblyPath);

            // Install the appDomainCallback to prepare the new app domain
            appDomain.DoCallBack(appDomainCallback.RegisterAssemblyLoad);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:22,代码来源:AppDomainShadow.cs

示例11: Main

        public static int Main(string[] args)
        {
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            _serverAppDomain = AppDomain.CreateDomain("Server", null, setup);
            _serverAppDomain.Load(typeof(ZyanConnection).Assembly.GetName());

            CrossAppDomainDelegate serverWork = new CrossAppDomainDelegate(() =>
            {
                var server = EventServer.Instance;
                if (server != null)
                {
                    Console.WriteLine("Event server started.");
                }
            });
            _serverAppDomain.DoCallBack(serverWork);

            // Test IPC Binary
            int ipcBinaryTestResult = IpcBinaryTest.RunTest();
            Console.WriteLine("Passed: {0}", ipcBinaryTestResult == 0);

            // Test TCP Binary
            int tcpBinaryTestResult = TcpBinaryTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpBinaryTestResult == 0);

            // Test TCP Custom
            int tcpCustomTestResult = TcpCustomTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpCustomTestResult == 0);

            // Test TCP Duplex
            int tcpDuplexTestResult = TcpDuplexTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpDuplexTestResult == 0);

            // Test HTTP Custom
            int httpCustomTestResult = HttpCustomTest.RunTest();
            Console.WriteLine("Passed: {0}", httpCustomTestResult == 0);

            // Test NULL Channel
            const string nullChannelResultSlot = "NullChannelResult";
            _serverAppDomain.DoCallBack(new CrossAppDomainDelegate(() =>
            {
                int result = NullChannelTest.RunTest();
                AppDomain.CurrentDomain.SetData(nullChannelResultSlot, result);
            }));
            var nullChannelTestResult = Convert.ToInt32(_serverAppDomain.GetData(nullChannelResultSlot));
            Console.WriteLine("Passed: {0}", nullChannelTestResult == 0);

            // Stop the event server
            EventServerLocator locator = _serverAppDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "IntegrationTest_DistributedEvents.EventServerLocator") as EventServerLocator;
            locator.GetEventServer().Dispose();
            Console.WriteLine("Event server stopped.");

            if (!MonoCheck.IsRunningOnMono || MonoCheck.IsUnixOS)
            {
                // Mono/Windows bug:
                // AppDomain.Unload freezes in Mono under Windows if tests for
                // System.Runtime.Remoting.Channels.Tcp.TcpChannel were executed.
                AppDomain.Unload(_serverAppDomain);
                Console.WriteLine("Server AppDomain unloaded.");
            }

            if (ipcBinaryTestResult + tcpBinaryTestResult + tcpCustomTestResult + tcpDuplexTestResult + httpCustomTestResult + nullChannelTestResult == 0)
            {
                Console.WriteLine("All tests passed.");
                return 0;
            }

            return 1;
        }
开发者ID:yallie,项目名称:zyan,代码行数:70,代码来源:Program.cs

示例12: GetCreator

        internal static IPluginCreator GetCreator(AppDomain domain, ILoggerFactory logfactory)
        {
            if (domain == null)
            throw new ArgumentNullException("domain");

              if (logfactory == null)
            throw new ArgumentNullException("logfactory");

              IPluginCreator creator = domain.GetData(PLUGINCREATORKEY) as IPluginCreator;
              if (creator == null)
              {
            domain.SetData(LOGGERFACTORYKEY, new ProxyLoggerFactory(logfactory));
            domain.DoCallBack(() =>
            {
              Logger.Singleton.LoggerFactory = AppDomain.CurrentDomain.GetData(LOGGERFACTORYKEY) as ILoggerFactory;
              AppDomain.CurrentDomain.SetData(PLUGINCREATORKEY, new PluginCreator());
            });
            domain.SetData(LOGGERFACTORYKEY, null);
            creator = domain.GetData(PLUGINCREATORKEY) as IPluginCreator;
              }
              return creator;
        }
开发者ID:CodeFork,项目名称:PluginFramework-1,代码行数:22,代码来源:PluginCreator.cs

示例13: LoadPluginsIntoAppDomain

 private static void LoadPluginsIntoAppDomain()
 {
     lock (SyncLock)
     {
         pluginDomain = AppDomain.CreateDomain("PluginDomain");
         pluginDomain.UnhandledException += (sender, e) => Logger.Error("Plugin app-domain crashed.", (Exception)e.ExceptionObject);
         pluginDomain.DoCallBack(() => log4net.Config.XmlConfigurator.Configure(new FileInfo(Path.Combine(InstallationDirectory, "NpsPlugin.config"))));
         pluginDomain.DoCallBack(LoadPlugins);
     }
 }
开发者ID:ibauersachs,项目名称:OpenCymd.Nps,代码行数:10,代码来源:NpsPlugin.cs

示例14: LoadFrom

 public static void LoadFrom(AppDomain appDomain,string file)
 {
     appDomain.SetData(Thread.CurrentThread.ManagedThreadId + "LoadFile", file);
     appDomain.DoCallBack(() =>
     {
         Assembly ass2 = Assembly.LoadFrom((string)AppDomain.CurrentDomain.GetData(Thread.CurrentThread.ManagedThreadId + "LoadFile"));
     });
 }
开发者ID:wangjianglin,项目名称:dotnet-core,代码行数:8,代码来源:Utils.cs

示例15: RunInAppDomain

        public static object RunInAppDomain(Delegate delg, AppDomain targetDomain, params object[] args) {
            var runner = new domainDomainRunner(delg, args, delg.GetHashCode());
            targetDomain.DoCallBack(runner.Invoke);

            return targetDomain.GetData("appDomainResult" + delg.GetHashCode());
        }
开发者ID:aries544,项目名称:eXpand,代码行数:6,代码来源:DomainRunner.cs


注:本文中的System.AppDomain.DoCallBack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。