private Injector(bool showOutputInWindow) { // I don't like the UI as dependency to the dll, but then again this is a unit test dll so it should be OK // Should introduce UI separately (perhaps the UI itself is the parameter on the constructor, that's it!!) // like this // public Injector(UIObject debugWindow) -- next version :) InjectionHelper.Initialize(showOutputInWindow); CurrentStatus = InjectionHelper.Status.Uninitialized; var errorCountAllowed = 100; // TODO: need to fix threading to actaully wait on a callback InjectionHelper.Log("Initializing Injector."); try { Thread.Sleep(1500); // TODO: need to fix threading to actaully wait on a callback do { CurrentStatus = InjectionHelper.GetStatus(); InjectionHelper.Log("Checking status."); if (CurrentStatus.ToString().ToUpper().Contains("ERROR")) { Log(string.Format("Injector Initialization Error or Delay: {0} {1} Retries remaining ", new object[] { CurrentStatus.ToString(), errorCountAllowed })); if (errorCountAllowed-- <= 0) { break; } } } while (CurrentStatus != InjectionHelper.Status.Ready); if (CurrentStatus == InjectionHelper.Status.Ready) { IniALL.Ini(); } } catch (Exception e) { InjectionHelper.Log("Error during Injector Intialization :" + e.Message); } }
private void Form1_Load(object sender, EventArgs e) { foreach (Control ctrl in this.Controls) { if (ctrl is Button) { ctrl.Enabled = false; } } txtOutput.Text = @"Injection is being initialized for CLR/JIT... This may take a short while because it is searching the address from PDB symbol file."; InjectionHelper.Initialize(); Thread thread = new Thread(WaitForInitialization); thread.Start(); thread.Join(); IniALL.Ini(); this.Text = this.Text + Description.GetDescription + (AOP.It2015 ? " 2015/2017" : " 2012"); }