public void simple_file_output() { AppDomain app = TestUtil.CreateDomain("simple-file-output.xml"); app.DoCallBack(() => { Log.Write(LoggerLevel.Error, "Simple file output."); Log.Write(LoggerLevel.Warn, "Simple file output.", new { additional_data = 3 }); }); }
public static int test_0_unload_with_threadpool() { AppDomain domain = AppDomain.CreateDomain("test_0_unload_with_threadpool"); domain.DoCallBack(new CrossAppDomainDelegate(invoke_workers)); AppDomain.Unload(domain); return(0); }
public void Cleanup() { if (strategyKind != AnalysisStrategyKind.ONDEMAND_ORLEANS) { return; } hostDomain.DoCallBack(ShutdownSilo); }
public static void LoadComponents(IList <ConfuserComponent> protections, IList <ConfuserComponent> packers, string pluginPath) { var ctx = new CrossDomainContext(protections, packers, pluginPath); AppDomain appDomain = AppDomain.CreateDomain(""); appDomain.SetData("ctx", ctx); appDomain.DoCallBack(CrossDomainLoadComponents); AppDomain.Unload(appDomain); }
private void button15_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; AppDomain otherDomain = AppDomain.CreateDomain("RandomCalls"); otherDomain.DoCallBack(new CrossAppDomainDelegate(_domCallbacks.RandomCall)); AppDomain.Unload(otherDomain); Cursor = Cursors.Default; }
private void appendToFileBtn_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; SetAppendMode(); AppDomain otherDomain = AppDomain.CreateDomain("AppendToFile"); if (textFileChk.Checked) { otherDomain.DoCallBack(new CrossAppDomainDelegate(_domCallbacks.AppendToTextFile)); } else { otherDomain.DoCallBack(new CrossAppDomainDelegate(_domCallbacks.AppendToFile)); } AppDomain.Unload(otherDomain); Cursor = Cursors.Default; }
private void CreateDomain(string path) { AppDomain FabDomain = AppDomain.CreateDomain("Fabric Domain " + Convert.ToString(btnCount), null, setup); this.path = path; FabDomain.DoCallBack(CreateFabric); Domains.Add(FabDomain); }
private static void PreloadNextAppDomain(bool firstLoad) { if (preloadAppDomainWaitHandle == null) { preloadAppDomainWaitHandle = new AutoResetEvent(false); } else { preloadAppDomainWaitHandle.Reset(); } new Thread(delegate() { preloadFailed = false; string entryPointArgEx = entryPointArg + "|Preloading=true"; if (!firstLoad) { entryPointArgEx += "|Reloading=true"; } string appDomainName = "Domain" + Environment.TickCount + " " + appDomainCount++; AppDomainSetup appDomainSetup = new AppDomainSetup(); appDomainSetup.ApplicationBase = currentAssemblyDirectory; appDomainSetup.ApplicationName = appDomainName; if (ShadowCopyAssembly) { appDomainSetup.ShadowCopyFiles = "true"; // Main assembly must be in the same or sub directory (limitation of PrivateBinPath) string subDirectory; IsSameOrSubDirectory(currentAssemblyDirectory, mainAssemblyDirectory, out subDirectory); if (!string.IsNullOrEmpty(subDirectory)) { appDomainSetup.PrivateBinPath = subDirectory; } } //preloadAppDomain = AppDomain.CreateDomain(appDomainName, null, mainAssemblyDirectory, ".", false); preloadAppDomain = AppDomain.CreateDomain(appDomainName, null, appDomainSetup); try { AssemblyLoader loader = new AssemblyLoader(assemblyPath, entryPointType, entryPointMethod, entryPointArgEx, hotreloadData, true); preloadAppDomain.DoCallBack(loader.Load); } catch (Exception e) { MessageBox.Show("Failed to create AppDomain for \"" + assemblyPath + "\" " + Environment.NewLine + Environment.NewLine + e, errorMsgBoxTitle); preloadFailed = true; UnloadAppDomain(preloadAppDomain); } preloadAppDomainWaitHandle.Set(); }).Start(); }
static void Main(string[] args) { // The Orleans silo environment is initialized in its own app domain in order to more // closely emulate the distributed situation, when the client and the server cannot // pass data via shared memory. AppDomain hostDomain = AppDomain.CreateDomain("OrleansHost", null, new AppDomainSetup { AppDomainInitializer = InitSilo, AppDomainInitializerArguments = args, }); GrainClient.Initialize(); // default OrleansClientConfiguration.xml // TODO: once the previous call returns, the silo is up and running. // This is the place your custom logic, for example calling client logic // or initializing an HTTP front end for accepting incoming requests. Console.WriteLine("Orleans Silo is running.\nEnter exit to terminate..."); Console.ReadLine(); const string systemGrainName1 = "vehicle1"; const string systemGrainName2 = "vehicle2"; foreach (var deviceGrainId in Enumerable.Range(1, 11)) { GrainClient.GrainFactory.GetGrain <IDeviceGrain>(deviceGrainId) .JoinSystem(deviceGrainId > 5 ? systemGrainName2 : systemGrainName1) .Wait(); } var observer = GrainClient.GrainFactory.CreateObjectReference <ISystemObserver>(new SystemObserver()).Result; GrainClient.GrainFactory.GetGrain <ISystemGrain>(systemGrainName1).Subscribe(observer); GrainClient.GrainFactory.GetGrain <ISystemGrain>(systemGrainName2).Subscribe(observer); var grain = GrainClient.GrainFactory.GetGrain <IDecodeGrain>(1); string line = null; while (line != "exit") { line = Console.ReadLine(); var parts = line.Split(','); if (parts.Length == 2 && int.TryParse(parts[0], out int res) && double.TryParse(parts[1], out double temperature)) { grain.Decode(line); } else if (line == "exit") { hostDomain.DoCallBack(ShutdownSilo); } else { Console.WriteLine("Not supported command"); } } }
static void Main(string[] args) { // The Orleans environment is initialized in its own app domain in order to more // closely emulate the distributed situation, when the client and the server cannot // pass data via shared memory. AppDomain hostDomain = AppDomain.CreateDomain("OrleansHost", null, new AppDomainSetup { AppDomainInitializer = InitSilo, AppDomainInitializerArguments = args, }); Orleans.OrleansClient.Initialize("DevTestClientConfiguration.xml"); var maleGrain = PersonFactory.GetGrain(1); // If the name is set, we've run this code before. if (maleGrain.FirstName.Result == null) { maleGrain.Register(new PersonalAttributes { FirstName = "John", LastName = "Doe", Gender = GenderType.Male }).Wait(); Console.WriteLine("We just wrote something to the persistent store (Id: {0}). Please verify!", maleGrain.GetPrimaryKey()); } else { Console.WriteLine("\n\nThis was found in the persistent store: {0}, {1}, {2}\n\n", maleGrain.FirstName.Result, maleGrain.LastName.Result, maleGrain.Gender.Result.ToString()); } var femaleGrain = PersonFactory.GetGrain(2); // If the name is set, we've run this code before. if (femaleGrain.FirstName.Result == null) { femaleGrain.Register(new PersonalAttributes { FirstName = "Alice", LastName = "Williams", Gender = GenderType.Female }).Wait(); Console.WriteLine("We just wrote something to the persistent store (Id: {0}). Please verify!", femaleGrain.GetPrimaryKey()); } else { Console.WriteLine("\n\nThis was found in the persistent store: {0}, {1}, {2}\n\n", femaleGrain.FirstName.Result, femaleGrain.LastName.Result, femaleGrain.Gender.Result.ToString()); } femaleGrain.Marry(maleGrain.GetPrimaryKey(), maleGrain.LastName.Result); Console.WriteLine("Orleans Silo is running.\nPress Enter to terminate..."); Console.ReadLine(); hostDomain.DoCallBack(ShutdownSilo); }
public static void Main() { // Show information for the default application domain. ShowDomainInfo(); // Create a new application domain and display its information. AppDomain newDomain = AppDomain.CreateDomain("MyMultiDomain"); newDomain.DoCallBack(new CrossAppDomainDelegate(ShowDomainInfo)); }
public void TestPlayerNamesPersistOnGameStart() { AppDomain dmn = AppDomain.CreateDomain("TestPlayerNamesPersistOnGameStart", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation); dmn.DoCallBack(TestPlayerNamesPersistOnGameStart_TestLogic); Assert.IsTrue((bool)dmn.GetData("AssertIsTrue")); }
public void TestGameOver_NewGame() { AppDomain dmn = AppDomain.CreateDomain("TestGameStart_WithPlayerNames_WithDefaultSize", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation); dmn.DoCallBack(TestGameOver_NewGame_TestLogic); Assert.IsTrue((bool)dmn.GetData($"AssertTrue")); }
private static void RunDifrent(int i) { AppDomain ap = AppDomain.CreateDomain(i.ToString()); ap.DoCallBack(() => { using (var game = new Game1()) game.Run(); } ); }
public static void DoCallBack <TCallback, TSerializer>( this AppDomain domain, TCallback callback, TSerializer serializer) #endif where TCallback : ICrossAppDomainCallback where TSerializer : ITextSerialization, new() { domain.SetData(CrossDomainActionId.Id, serializer.ToText(callback)); domain.DoCallBack(DoCallBack <TCallback, TSerializer>); }
static void Main(string[] args) { // The Orleans silo environment is initialized in its own app domain in order to more // closely emulate the distributed situation, when the client and the server cannot // pass data via shared memory. // Removing this to make it a standalone silo. AppDomain hostDomain = AppDomain.CreateDomain("OrleansHost", null, new AppDomainSetup { AppDomainInitializer = InitSilo, AppDomainInitializerArguments = args, }); Orleans.GrainClient.Initialize("DevTestClientConfiguration.xml"); // TODO: once the previous call returns, the silo is up and running. // This is the place your custom logic, for example calling client logic // or initializing an HTTP front end for accepting incoming requests. Console.WriteLine("Orleans Silo is running.\nPress Enter to terminate..."); var deviceGrain = GrainClient.GrainFactory.GetGrain <IDeviceGrain>(3); deviceGrain.JoinSystem("vehicle1").Wait(); deviceGrain = GrainClient.GrainFactory.GetGrain <IDeviceGrain>(4); deviceGrain.JoinSystem("vehicle1").Wait(); deviceGrain = GrainClient.GrainFactory.GetGrain <IDeviceGrain>(5); deviceGrain.JoinSystem("vehicle1").Wait(); var observer = new SystemObserver(); var observerRef = SystemObserverFactory.CreateObjectReference(observer).Result; var systemGrain = GrainClient.GrainFactory.GetGrain <ISystemGrain>(0, keyExtension: "vehicle1"); systemGrain.Subscribe(observerRef).Wait(); var grain = GrainClient.GrainFactory.GetGrain <IDecodeGrain>(0); while (true) { grain.Decode(Console.ReadLine()); } //// this was part of prior sample. not changed in stand alone. ////while (true) ////{ //// var grain = GrainClient.GrainFactory.GetGrain<IDeviceGrain>(0); //// grain.SetTemprature(double.Parse(Console.ReadLine())); ////} //// stand alone change. hostDomain.DoCallBack(ShutdownSilo); }
public static void CompileAndRun(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args) { if (ChildDomain == null) { ChildDomain = AppDomain.CreateDomain("CSharpRunner", AppDomain.CurrentDomain.Evidence, GetAssemblyPath(), ".", false); } var invoker = new ScriptInvoker(client, args); ChildDomain.DoCallBack(invoker.Invoke); }
static void Main() { AppDomain domain = AppDomain.CreateDomain("new-domain"); domain.DoCallBack(Run); Type stType = typeof(Something <string, string>); Other <string, string> st = (Other <string, string>)domain.CreateInstanceAndUnwrap(stType.Assembly.FullName, stType.FullName); Console.WriteLine("in main int: {0}", st.getInt()); Console.WriteLine("in main types: {0}", st.getTypeNames <Test> ()); }
void ThreadB(object obj) { // Console.WriteLine ("ThreadB"); try { ad2.DoCallBack(B2); ad1.DoCallBack(B1); } catch (Exception ex) { mbro.message = string.Format("ThreadB exception: {0}", ex); } // Console.WriteLine ("ThreadB Done"); }
public void GetPossibleKeys_NullAppHost_ReturnsDefault() { const string key = "findMe"; noHost.DoCallBack(() => { var values = KeyUtilities.GetPossibleKeys(key); values.Count().Should().Be(1); values.First().Should().Be($"ss/{key}"); }); }
private void button12_Click(object sender, EventArgs e) { WaitCallback wc = new WaitCallback(o => { AppDomain otherDomain = AppDomain.CreateDomain("ControlledLogging"); otherDomain.DoCallBack(new CrossAppDomainDelegate(_domCallbacks.ControlledLogging)); AppDomain.Unload(otherDomain); }); ThreadPool.QueueUserWorkItem(wc); }
static void Main(string[] args) { AppDomain appDomain = AppDomain.CreateDomain("MyTemp"); appDomain.DoCallBack(loadAssembly); appDomain.DomainUnload += appDomain_DomainUnload; AppDomain.Unload(appDomain); AppDomain appDomain2 = AppDomain.CreateDomain("MyTemp2"); appDomain2.DoCallBack(loadAssembly); }
public static void LoadToDomain(AppDomain domain, List <string> dlls) { foreach (string dll in dlls) { AppDomainHelper asmLoad = new AppDomainHelper() { AsmData = File.ReadAllBytes(dll) }; domain.DoCallBack(new CrossAppDomainDelegate(asmLoad.LoadAsm)); } }
//static IAsyncStream<MetricsSnapshot> SiloSnapshotStream; static void Main(string[] args) { //var SyncContext = new SynchronizationContext(); //SynchronizationContext.SetSynchronizationContext(SyncContext); // The Orleans silo environment is initialized in its own app domain in order to more // closely emulate the distributed situation, when the client and the server cannot // pass data via shared memory. AppDomain hostDomain = AppDomain.CreateDomain("OrleansHost", null, new AppDomainSetup { AppDomainInitializer = InitSilo, AppDomainInitializerArguments = args, }); var config = ClientConfiguration.LocalhostSilo(); config.AddSimpleMessageStreamProvider("SimpleStreamProvider"); //config.DefaultTraceLevel = Runtime.Severity.Verbose; GrainClient.Initialize(config); // TODO: once the previous call returns, the silo is up and running. // This is the place your custom logic, for example calling client logic // or initializing an HTTP front end for accepting incoming requests. // configure and start the reporting of silo metrics // UNCOMMENT BELOW to override configuration defaults var metrics = GrainClient.GrainFactory.GetGrain <IClusterMetricsGrain>(Guid.Empty); metrics.Configure(new MetricsConfiguration { Enabled = true, // default SamplingInterval = TimeSpan.FromSeconds(1), // default ConfigurationInterval = TimeSpan.FromSeconds(10), // default StaleSiloMetricsDuration = TimeSpan.FromSeconds(10), // default TrackExceptionCounters = true, TrackMethodGrainCalls = true, StreamingProviderName = "SimpleStreamProvider", HistoryLength = 30 // default }).Ignore(); // TODO: put together a better demo // start our silly demo simulation var sim = GrainClient.GrainFactory.GetGrain <ISimulatorGrain>(Guid.Empty); sim.StartSimulation(TimeSpan.FromMinutes(10), 200, 200, true).Ignore(); SubscribeToStream().Wait(); Console.WriteLine("Orleans Silo is running.\nPress Enter to terminate..."); Console.ReadLine(); hostDomain.DoCallBack(ShutdownSilo); }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void Load() { if (loaded_) { return; } loaded_ = true; AppDomain queryPluginAppDomain = AppDomain.CreateDomain("WwwProxy_queryPluginAppDomain"); queryPluginAppDomain.DoCallBack(new CrossAppDomainDelegate(CrossAppDomainLoad)); AppDomain.Unload(queryPluginAppDomain); if (crossDomainException_ != null) { WwwProxy.Instance.OnError(null, null, crossDomainException_, crossDomainException_.Message); } foreach (Assembly a in loadedAssemblies_) { IPlugin plugin = null; foreach (Type t in a.GetTypes()) { if (t.IsClass) { foreach (Type i in t.GetInterfaces()) { if (i.FullName == "WwwProxy.IPlugin") { try { plugin = (IPlugin)System.Activator.CreateInstance(t); plugin.Initialise(); } catch (Exception e) { plugin = null; WwwProxy.Instance.OnError(null, null, e, e.Message); } break; } } } if (plugin != null) { loadedPlugins_.Add(plugin); break; } } } }
public void detect_parent_logger_cycles() { AppDomain app = TestUtil.CreateDomain("invalid-logs-with-cycles.xml"); app.DoCallBack(() => { var it = Logger.FromName("a"); Assert.True(it.ForwardToParentBlocked); it = Logger.FromName("f"); Assert.False(it.ForwardToParentBlocked); }); }
public static void Main() { AppDomain otherDomain = AppDomain.CreateDomain("otherDomain"); greetings = "PING!"; MyCallBack(); otherDomain.DoCallBack(new CrossAppDomainDelegate(MyCallBack)); // Output: // PING! from defaultDomain // PONG! from otherDomain }
private static void Demo2() { AppDomain domainA = AppDomain.CreateDomain("MyDomainA"); AppDomain domainB = AppDomain.CreateDomain("MyDomainB"); domainA.SetData("DomainKey", "Domain A Value"); domainB.SetData("DomainKey", "Domain B Value"); OutPutCall(); domainA.DoCallBack(OutPutCall); // CrossAppDomainDelegate call domainB.DoCallBack(OutPutCall); // CrossAppDomainDelegate call Console.ReadLine(); }
static int Main () { AppDomain.Unload (AppDomain.CreateDomain ("Warmup unload code")); Console.WriteLine ("."); ad = AppDomain.CreateDomain ("NewDomain"); ad.DoCallBack (Bla); var t = new Thread (UnloadIt); t.IsBackground = true; t.Start (); evt.WaitOne (); return 0; }
static int Main() { AppDomain app = AppDomain.CreateDomain("Foo"); Console.WriteLine("I'm on {0}", AppDomain.CurrentDomain); app.DoCallBack(Driver.OtherDomain); Thread.Sleep(1); AppDomain.Unload(app); Thread.Sleep(1); return(0); }
private static void RunInPartialTrust(CrossAppDomainDelegate testMethod) { Assert.True(Assembly.GetExecutingAssembly().IsFullyTrusted); AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); PermissionSet perms = PermissionsHelper.InternetZone; AppDomain domain = AppDomain.CreateDomain("PartialTrustSandBox", null, setup, perms); domain.DoCallBack(testMethod); }
public void Foo(AppDomain ad) { ad.DoCallBack (new CrossAppDomainDelegate (Bar)); }
public static void Go() { // Create an AppDomain s_ad = AppDomain.CreateDomain("AD #2", null, null); // Spawn thread to enter the other AppDomain Thread t = new Thread((ThreadStart)delegate { s_ad.DoCallBack(Loop); }); t.Start(); Thread.Sleep(5000); // The other thread a chance to run Stopwatch sw = null; try { // Time how long it takes to unload the AppDomain Console.WriteLine("Calling unload"); sw = Stopwatch.StartNew(); AppDomain.Unload(s_ad); } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.WriteLine("Unload returned after {0}", sw.Elapsed); Console.ReadLine(); }