raise

EventHandler is null

99封情书 提交于 2019-12-09 15:46:01
问题 I am trying to raise a click event from User control and handle it on the containing page. The problem I have is, when I click the button 'imgstep1' on the user control, the code behind imgstep1_click event triggers and but the 'btnHandler' event is alway null. Hence it doesnt call the parent event. Any help on this will be much appreciated. My User Control Code is : .ascx code: <asp:ImageButton ImageUrl="./images/step1.gif" ID="imgstep1" runat="server" OnClick="imgstep1_Click"/> .ascx.cs

Python reraise/recatch exception

天大地大妈咪最大 提交于 2019-12-09 14:39:57
问题 I would like to know if it is possible in python to raise an exception in one except block and catch it in a later except block. I believe some other languages do this by default. Here is what it would look like" try: something except SpecificError as ex: if str(ex) = "some error I am expecting" print "close softly" else: raise except Exception as ex: print "did not close softly" raise I want the raise in the else clause to trigger the final except statement. In actuality I am not printing

how to raise event with timer?

核能气质少年 提交于 2019-12-08 02:09:35
问题 ok so i have two classes each with timers set at different intervals. one goes off every 2 seconds, the other every 2 minutes. each time the code runs under the timer i want it to raise an event with the string of data the code generates. then i want to make another class that subscribes to the event args from the other classes and does something like write to console whenever an event is fired. and since one class only fires every 2 minutes this class can store the last event in a private

how to raise event with timer?

三世轮回 提交于 2019-12-06 09:48:31
ok so i have two classes each with timers set at different intervals. one goes off every 2 seconds, the other every 2 minutes. each time the code runs under the timer i want it to raise an event with the string of data the code generates. then i want to make another class that subscribes to the event args from the other classes and does something like write to console whenever an event is fired. and since one class only fires every 2 minutes this class can store the last event in a private field and reuse that every time until a new event is fired to update that value. So, how do i raise an

How to disable all exception raising in Delphi?

淺唱寂寞╮ 提交于 2019-12-05 17:56:08
Is there a way to disable all the dialog boxes when an exception or error occurs(like access violations, indy socket errors, timeouts etc.)? They are thrown sometimes in my program, but these errors aren't fatal in any way and can be ignored, just the dialog boxes are disturbing. I use Delphi 7. If you just don't wont to show the exception window then go to: Tools/Options/Debugger Options/Language Exceptions and disable CheckBox Notify on language exceptions . That is walid for Delphi 2010. (I don't remember if it is the same CheckBox in Delphi 7). EDIT: In some cases the exceptions are

How to imitate Python 3's raise … from in Python 2?

ぃ、小莉子 提交于 2019-12-05 09:47:18
问题 Python 3 has the neat try: raise OneException('sorry') except OneException as e: # after a failed attempt of mitigation: raise AnotherException('I give up') from e syntax which allows raising a followup exception without loosing context. The best analogy I could come up with in Python 2 is raise AnotherException((e,'I give up')), None, sys.exc_info()[2] where the (e,'') is an ugly hack to have the original exception's name included in the message. But isn't there a better way? 回答1: There's a

Is it OK to raise a built-in exception, but with a different message, in Python?

梦想的初衷 提交于 2019-12-05 09:22:08
问题 Is it OK to raise a built-in exception with a custom text? or to raise a built-in warning also with custom text? The documentation reads: exception ValueError: Raised when a built-in operation or function receives an argument (…) Is it implied that only built-in operations should raise a ValueError exception? In practice, I understand that it is safe to create an exception class that inherits from ValueError or Exception. But is it OK not to do that, and directly raise a ValueError("custom

Raise an event in C# [duplicate]

≡放荡痞女 提交于 2019-12-04 15:46:59
问题 This question already has answers here : Checking for null before event dispatching… thread safe? (6 answers) Closed 3 months ago . I came across this question in a Microsoft Practice Test and I got confused. Here is the question: Which of the following C# code samples is the proper way to raise an event, assuming that the Alarm event, the AlarmEventArgs class, and the AlarmEventHandler delegate have been declared? Here is the "correct" answer they provided: AlarmEventArgs e = new

EventHandler is null

早过忘川 提交于 2019-12-04 02:37:19
I am trying to raise a click event from User control and handle it on the containing page. The problem I have is, when I click the button 'imgstep1' on the user control, the code behind imgstep1_click event triggers and but the 'btnHandler' event is alway null. Hence it doesnt call the parent event. Any help on this will be much appreciated. My User Control Code is : .ascx code: <asp:ImageButton ImageUrl="./images/step1.gif" ID="imgstep1" runat="server" OnClick="imgstep1_Click"/> .ascx.cs code : public delegate void OnImageButtonClick(); public event OnImageButtonClick btnHandler; protected

How to imitate Python 3's raise … from in Python 2?

十年热恋 提交于 2019-12-03 23:59:12
Python 3 has the neat try: raise OneException('sorry') except OneException as e: # after a failed attempt of mitigation: raise AnotherException('I give up') from e syntax which allows raising a followup exception without loosing context. The best analogy I could come up with in Python 2 is raise AnotherException((e,'I give up')), None, sys.exc_info()[2] where the (e,'') is an ugly hack to have the original exception's name included in the message. But isn't there a better way? There's a raise_from in python-future ; simply install it pip install future and import to use from future.utils