private void BtnDone_Click(object sender, EventArgs e) { ClientID = dh.ClientID(cmbNameSurname.Text, cmbCell.Text, cmbPhoneNumber.Text); double deposit; foreach (Trophee item in lstTrophee) { double mountType = dh.ReturnMountType(dh.SelectAnimalType(item.Animaltype), dh.SelectMountType(item.Mounttype)); dh.Insert(item.Invoicenumber, item.Number, item.Amount, item.Remarks, mountType, item.Total, item.Date, item.Deposit, item.Discount); } int InvoiceNumber = int.Parse(lblInvoice.Text); double credit; deposit = CalculateTotalPrice / 2; double CTotal = dh.GetCredit(ClientID); if (CalculateTotalPrice >= CTotal) { CTotal = CalculateTotalPrice - CTotal; } else { credit = CTotal; credit = CTotal - CalculateTotalPrice; CTotal = 0; dh.UpdateCredit(credit, ClientID); } dh.InsertFaktuur(InvoiceNumber, ClientID, CalculateTotalPrice, CTotal, deposit, txtClientNumber.Text, txtClientName.Text, cmbHandler.Text); this.Close(); MyEventHandler?.Invoke(); }
public void When_Publishing_An_Event_To_The_Processor() { _commandProcessor.Publish(_myEvent); //_should_publish_the_command_to_the_event_handlers Assert.True(MyEventHandler.ShouldReceive(_myEvent)); }
static event MyEventHandler SomeEvent; // событие public static void EventsSample() { SomeEvent += new MyEventHandler(handler1); SomeEvent += new MyEventHandler(handler2); // Генерируем событие OnSomeEvent(); }
public void When_A_Message_Is_Dispatched_It_Should_Reach_A_Handler() { _messagePump.Run(); //_should_dispatch_the_message_to_a_handler Assert.True(MyEventHandler.ShouldReceive(_event)); }
void EventsTest() { void EventFromSource() { int i = 0; MyEventHandler eh = () => Use(i); this.Click += eh; Click(); i = 0; // Should *not* get an SSA definition (`Click` is not called after addition) MyEventHandler eh2 = () => Use(i); this.Click += eh2; } void EventFromLibrary() { var i = 0; // Should *not* get an SSA definition, but does because of the imprecise implicit read below using (var p = new System.Diagnostics.Process()) { EventHandler exited = (object s, EventArgs e) => Use(i); p.Exited += exited; // Imprecise implicit read of `i`; an actual read would happen in a call to e.g. `p.Start()` or `p.OnExited()` } } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); _show += new MyEventHandler(Cat); _show += new MyEventHandler(Dog); _show += new MyEventHandler(Mouse); _show += new MyEventHandler(Mouse); _show.Invoke(); //Aufrufen der drangehängten Methoden //Beispiel 2: Like a WinForm - Button Button b1 = new Button(); b1.KlickEvent += MeineKlickLogik; b1.KlickEvent += Logger; b1.Klick(); //b1.KlickEvent = null; // absolut verboten b1.KlickEvent -= Logger; b1.Klick(); Console.ReadLine(); }
static void Main(string[] args) { Random random = new Random(); int count = 0; PFEvent = new MyEventHandler(RaiseEvent); temperature = 70; while (true) { temperature += random.Next(-1, 2); if (temperature < 65 || temperature > 75) { if (temperature < 65) { PFEvent("Temperature below threshold..warming up", 1); } else { PFEvent("Temperature above threshold..cooling down", -1); } } Console.WriteLine($"Temperature {temperature}"); //count++; System.Threading.Thread.Sleep(500); } }
public Form1() { InitializeComponent(); //イベントハンドラを作成 myEvent = new MyEventHandler(event_DataReceived); xxx_process = new Process(); // パス指定 //xxx_process.StartInfo.FileName = XXX_Path; xxx_process.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec"); xxx_process.StartInfo.Arguments = "/K C:\\MongoDB\\bin\\mongo.exe"; // 非同期処理のために、ShellExecuteを使わない設定にする // BeginOutputReadLine()を利用するための条件 xxx_process.StartInfo.UseShellExecute = false; // 非同期読込での完了イベントとなるイベントハンドラを設定 // BeginOutputReadLine()を利用するための条件 xxx_process.OutputDataReceived += new DataReceivedEventHandler(process_DataReceived); // 標準入出力をリダイレクト xxx_process.StartInfo.RedirectStandardOutput = true; xxx_process.StartInfo.RedirectStandardError = true; xxx_process.StartInfo.RedirectStandardInput = true; // XXX.exeのコンソールは邪魔なので開かない xxx_process.StartInfo.CreateNoWindow = true; // ついにプロセス起動! xxx_process.Start(); // 標準出力の非同期読込を開始 xxx_process.BeginOutputReadLine(); }
public static void DispatchEvent(string evt, params object[] objs) { try { if (listeners.ContainsKey(evt)) { MyEventHandler handler = listeners[evt]; if (handler != null) { handler(objs); } } if (oneOfflisteners.ContainsKey(evt)) { MyEventHandler handler = oneOfflisteners[evt]; if (handler != null) { handler(objs); } //这里涉及到Dispath过程中反注册问题,必须使用listeners[type]-=.. oneOfflisteners[evt] -= handler; if (oneOfflisteners[evt] == null) { //已经没有监听者了,移除. oneOfflisteners.Remove(evt); } } } catch (System.Exception ex) { Debug.LogError(string.Format(szErrorMessage, evt, ex.Message, ex.StackTrace)); } }
public GameOfLifeClass() { _myFireUpdater = OnFireUpdate; _aliveCells = new Dictionary<PointULong, Cell>(); _aroundAliveCells = new Dictionary<PointULong, Cell>(); }
public DatabasePage(MyEventHandler2 GoToMovieInsertPage, MyEventHandler GoToScheduleInsertPage, MyEventHandler GoToStatisticsPage) { InitializeComponent(); this.GoToMovieInsertPage = GoToMovieInsertPage; this.GoToScheduleInsertPage = GoToScheduleInsertPage; this.GoToStatisticsPage = GoToStatisticsPage; }
public UserHomePage(MyEventHandler fun1, MyEventHandler fun3, SchedulePage.MyEventHandler GoToSitePage) { InitializeComponent(); GoMovleListPage += fun1; GoRefundPage += fun3; schedulePage = new SchedulePage(GoToSitePage); OpenPage(); }
public JuegoVida(int maxX, int maxY, string SimboloAlgoritmo, int EdadMaxima, double OcupacionInicial) { MyFireUpdater = new MyEventHandler(OnFireUpdate); this.EdadMaxima = EdadMaxima; this.algoritmo = new Algoritmo(SimboloAlgoritmo); this.OcupacionInicial = OcupacionInicial; Init(maxX, maxY); }
protected virtual void OnAdded(MyCustomEventArgs e) { MyEventHandler handler = Added; if (handler != null) { handler(this, e); } }
public NewFormMain() { InitializeComponent(); Global.Params.InitializeBoxFlag = MBoxSDK.ConfigSDK.MBOX_Initialize(); //int i = MBoxSDK.ConfigSDK.MBOX_Login("10.20.31.1", "", "", ""); // bool b = MBoxSDK.ConfigSDK.MBOX_CreateSubscriber(i, 8000); LoadBoxError += new MyEventHandler(FormMain_LoadBoxError); tvTree.DragDropEnabled = false; }
private void Event(string result) { MyEventHandler handler = MyEvent; if (handler != null) { handler(result); } }
public QueueEvent CreateQueueEvent(string name, MyEventHandler listener) { QueueEvent ret = null; ret = new QueueEvent(name, listener, QueueEventFinished, DeleteEvent); queue_events.Add(ret); return(ret); }
public void RemoveEventListener(string type, MyEventHandler handler) { List <MyEventHandler> handlers = listeners[type]; if (handlers != null && handler != null && handlers.Contains(handler)) { handlers.Remove(handler); } }
private void UserControl1_Load(object sender, EventArgs e) { comboBox1.Items.Add("无飞行轨迹"); comboBox1.Items.Add("按照圆形轨迹飞行"); comboBox1.Items.Add("按照正弦曲线飞行"); AllMap(this, new EventArgs()); AngleChange += new EventHandler(AllMap); TrackOne += new EventHandler(MapOne); TrackTwo += new MyEventHandler(MapTwo); }
public event MyEventHandler RaiseEventTest; // declare an event from the delegate // METHODS public void Raise(CustomEvent e) // raise a specifitic custom event { MyEventHandler handler = RaiseEventTest; // assign a delegate with the event if (handler != null) { Console.WriteLine("Publishing an event."); handler(this, e); // raise it } }
public static void Main() { //Window w = new Window(); //w.Click += w_Click; //w.FireEvent(); // phát sinh sự kiện //Console.ReadLine(); MyEventHandler meh = new MyEventHandler(w_Click); meh += new MyEventHandler(e_Click); meh("hahaha"); }
/// <summary> /// Invokes the simple event. /// </summary> /// <returns>The result.</returns> protected int OnSimpleEvent() { MyEventHandler handler = this.SimpleEvent; if (handler != null) { handler(string.Empty); } return(-1); }
public async Task Should_Change_TenantId_If_EventData_Is_MultiTenant() { var tenantId = Guid.NewGuid(); var handler = new MyEventHandler(GetRequiredService <ICurrentTenant>()); LocalEventBus.Subscribe <EntityChangedEventData <MyEntity> >(handler); await LocalEventBus.PublishAsync(new EntityCreatedEventData <MyEntity>(new MyEntity(tenantId))); handler.TenantId.ShouldBe(tenantId); }
public MyEvent CreateEvent(string name, MyEventHandler listener) { DeleteEvent(name); MyEvent ret = null; ret = new MyEvent(name, listener, DeleteEvent); events.Add(ret); return(ret); }
/// <summary> /// Override OnBackPressed method /// </summary> public override void OnBackPressed() { if (mBtnLogin.Enabled) { MyEventHandler.Trigger(this, "Player", "Player One", null, false); Finish(); // Call Finish method when back button is pressed OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom); } base.OnBackPressed(); }
public void When_There_Are_Multiple_Subscribers() { _exception = Catch.Exception(() => _commandProcessor.Publish(_myEvent)); //_should_not_throw_an_exception Assert.Null(_exception); //_should_publish_the_command_to_the_first_event_handler Assert.True(MyEventHandler.ShouldReceive(_myEvent)); //_should_publish_the_command_to_the_second_event_handler Assert.True(MyOtherEventHandler.Shouldreceive(_myEvent)); }
public static void OneShot <TA>(this TA instance, string eventName, MyEventHandler handler) { EventInfo i = typeof(TA).GetEvent(eventName); MyEventHandler newHandler = null; newHandler = (sender, e) => { handler(sender, e); i.RemoveEventHandler(instance, newHandler); }; i.AddEventHandler(instance, newHandler); }
public async Task Should_Call_Created_And_Changed_Once() { var handler = new MyEventHandler(); LocalEventBus.Subscribe <EntityChangedEventData <MyEntity> >(handler); LocalEventBus.Subscribe <EntityCreatedEventData <MyEntity> >(handler); await LocalEventBus.PublishAsync(new EntityCreatedEventData <MyEntity>(new MyEntity())); handler.EntityCreatedEventCount.ShouldBe(1); handler.EntityChangedEventCount.ShouldBe(1); }
public async Task Should_Call_Created_And_Changed_Once() { var handler = new MyEventHandler(); EventBus.Register <EntityChangedEventData <MyEntity> >(handler); EventBus.Register <EntityCreatedEventData <MyEntity> >(handler); await EventBus.TriggerAsync(new EntityCreatedEventData <MyEntity>(new MyEntity())); handler.EntityCreatedEventCount.ShouldBe(1); handler.EntityChangedEventCount.ShouldBe(1); }
public void ShouldCallCreatedAndChangedOnce() { var handler = new MyEventHandler(); EventBus.Register <EntityChangedEventData <MyEntity> >(handler); EventBus.Register <EntityCreatedEventData <MyEntity> >(handler); EventBus.Trigger(new EntityCreatedEventData <MyEntity>(new MyEntity())); handler.EntityCreatedEventCount.ShouldBe(1); handler.EntityChangedEventCount.ShouldBe(1); }
public void Should_Call_Created_And_Changed_Once() { var handler = new MyEventHandler(); EventBus.Register <EntityChangedEventData <MyEntity> >(handler); EventBus.Register <EntityCreatedEventData <MyEntity> >(handler); EventBus.Publish(new EntityCreatedEventData <MyEntity>(new MyEntity())); handler.EntityCreatedEventCount.ShouldBe(1); handler.EntityChangedEventCount.ShouldBe(1); }
} //客户端唯一标识 //构造函数保存档期和座位并锁定座位,开始倒计时 public SiteStateTimer(MyEventHandler fun, Dictionary <string, string> Schedule, List <string> SiteIDs, int Timer_index, MyEventHandler1 OverTimer) { this.Schedule = Schedule; this.SiteIDs = SiteIDs; this.Timer_index = Timer_index; Delete += fun; this.OverTimer += OverTimer; LockSites(); //锁定座位 timer.Interval = 10000; //开始倒计时 timer.Elapsed += Timer_Elapsed; timer.Start(); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here handler += new MyEventHandler(StringHandler); handler1 += new MyEventHandler(IntHandler); string msg = Request.QueryString["msg"]; try { int no = int.Parse(msg); handler1(no); } catch { handler(msg); } finally { MyEventHandler mydelegate = new MyEventHandler(DelegateHandler); mydelegate(msg); } }
public void Start(IEnumerable<ICommand> list, int repeatTimes) { new Thread(delegate() { for (int i = 1; i <= repeatTimes; i++) { Console.WriteLine(i + " - Script start"); foreach (var v in list) { Console.WriteLine(v.Text); v.Run(); if (BreakEvent != null) { BreakEvent.Invoke(this, null); BreakEvent -= new MyEventHandler(OnBreakEvent); return; } } } Console.WriteLine("End script."); }).Start(); }
public EventTest() { myEventCls = new MyEventCls(); myEvent += new MyEventHandler(myEventCls.MyEventFunc); }
/** * @brief Create a new TeamTalk client instance. * * @param poll_based If the application using this class is a * Windows Forms application @a poll_based should be 'false' * since events will be posted using the Windows message * loop. In Console applications on the other hand, the user * application will have to 'poll' for events using * GetMessage(). Remember to put the @c [STAThread] macro on * the @c Main method if building a console application. */ public TeamTalk(bool poll_based) { Assembly assembly = Assembly.GetExecutingAssembly(); AssemblyName name = assembly.GetName(); Version dllversion = new Version(Marshal.PtrToStringUni((c_tt.TTDLL.TT_GetVersion()))); if (!name.Version.Equals(dllversion)) { string errmsg = String.Format("Invalid {2} version loaded. {2} is version {0} and {3} is version {1}", dllversion.ToString(), name.Version.ToString(), c_tt.TTDLL.dllname, c_tt.TTDLL.mgtdllname); throw new Exception(errmsg); } Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__AUDIOCODEC) == Marshal.SizeOf(new AudioCodec())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__BANNEDUSER) == Marshal.SizeOf(new BannedUser())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__VIDEOFORMAT) == Marshal.SizeOf(new VideoFormat())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__OPUSCODEC) == Marshal.SizeOf(new OpusCodec())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__CHANNEL) == Marshal.SizeOf(new Channel())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__CLIENTSTATISTICS) == Marshal.SizeOf(new ClientStatistics())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__REMOTEFILE) == Marshal.SizeOf(new RemoteFile())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__FILETRANSFER) == Marshal.SizeOf(new FileTransfer())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__MEDIAFILESTATUS) == Marshal.SizeOf(Enum.GetUnderlyingType(typeof(MediaFileStatus)))); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__STREAMTYPE) == Marshal.SizeOf(Enum.GetUnderlyingType(typeof(StreamType)))); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__SERVERPROPERTIES) == Marshal.SizeOf(new ServerProperties())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__SERVERSTATISTICS) == Marshal.SizeOf(new ServerStatistics())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__SOUNDDEVICE) == Marshal.SizeOf(new SoundDevice())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__SPEEXCODEC) == Marshal.SizeOf(new SpeexCodec())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__TEXTMESSAGE) == Marshal.SizeOf(new TextMessage())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__WEBMVP8CODEC) == Marshal.SizeOf(new WebMVP8Codec())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__USER) == Marshal.SizeOf(new User())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__USERACCOUNT) == Marshal.SizeOf(new UserAccount())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__USERSTATISTICS) == Marshal.SizeOf(new UserStatistics())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__VIDEOCAPTUREDEVICE) == Marshal.SizeOf(new VideoCaptureDevice())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__VIDEOCODEC) == Marshal.SizeOf(new VideoCodec())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__AUDIOCONFIG) == Marshal.SizeOf(new AudioConfig())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__SPEEXVBRCODEC) == Marshal.SizeOf(new SpeexVBRCodec())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__VIDEOFRAME) == Marshal.SizeOf(new VideoFrame())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__AUDIOBLOCK) == Marshal.SizeOf(new AudioBlock())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__AUDIOFORMAT) == Marshal.SizeOf(new AudioFormat())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__MEDIAFILEINFO) == Marshal.SizeOf(new MediaFileInfo())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__CLIENTERRORMSG) == Marshal.SizeOf(new ClientErrorMsg())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__DESKTOPINPUT) == Marshal.SizeOf(new DesktopInput())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__SPEEXDSP) == Marshal.SizeOf(new SpeexDSP())); Debug.Assert(TTDLL.TT_DBG_SIZEOF(TTType.__TTMESSAGE) == Marshal.SizeOf(new TTMessage())); if (poll_based) m_ttInst = TTDLL.TT_InitTeamTalkPoll(); else { m_eventhandler = new MyEventHandler(this); #if PocketPC IntPtr hWnd = m_eventhandler.Hwnd; #else m_eventhandler.CreateControl(); IntPtr hWnd = m_eventhandler.Handle; #endif m_ttInst = TTDLL.TT_InitTeamTalk(hWnd, MyEventHandler.WM_TEAMTALK_CLIENTEVENT); } }
public void RecipeLoadedEventFired() { XmlDocumentFactory.Type = typeof(XmlDocumentMock); XmlDocumentMock.PathName = "test.recipe"; XmlDocumentMock.RawContent = "<recipe></recipe>"; LoaderFactory.Type = typeof(LoaderMock); var handler = new MyEventHandler(); RecipeFactory.Loaded += handler.OnRecipeLoaded; RecipeFactory.Load("test.recipe"); Assert.True(handler.Loaded); }