static void Main() { //IContainer c = BootstrapContainer(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); NodeContext nc = null; NodeRecord rec = new NodeRecord(); string host = "localhost"; bool tryConnect = false; var connectForm = new ConnectForm(); connectForm.FormClosing += (s, ea) => { try { rec.NodeId = connectForm.NodeId; rec.OrgNodeId = -1; rec.QueueBaseName = connectForm.AppName; rec.QueueTransportSettings = TransportSettings.UseRabbitMq(connectForm.Host); host = connectForm.Host; tryConnect = true; } catch (Exception ex) { ea.Cancel = true; MessageBox.Show(connectForm, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; Application.Run(connectForm); if (connectForm.DialogResult != DialogResult.Cancel && tryConnect) { connectForm = null; var bus = ServiceBusFactory.New(sbc => { sbc.ReceiveFrom(rec.QueueUri); sbc.UseControlBus(); rec.QueueTransportSettings.ApplyGlobalConfig(sbc); }); // We got a node context, yay. // Launch a service which takes care of traffix, and provide some // means for the ClientForm to xommunixate with that service: var clientForm = new ClientForm(rec, bus); //LaunchMessageService(nc, svc => //{ Application.Run(clientForm); nc.Dispose(); //}); } }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }