开发者

(conditional) Multiple Event Handlers C#

A portion of my program requires a "flag" retrieval, that is I am fetching a value that is either True or False, and based on this return value two things could follow.

1) The flag is true, aka "go ahead", and I retrieve data from a database.

2) The flag is false, and I want to prevent the data from being retrieved.

Now, this check has to be performed before any function that would call upon the database in question. I decided to implement this check in the form of an event hand开发者_JAVA技巧ler attached to GUI objects that would trigger this data inquiry.

This check event handler is called first upon necessary events, and my question is:

How do I stop subsequent event handlers from firing if the FIRST event handler (my flag checker) comes up FALSE?

Thanks


Your design has a problem in depending upon the event mechanism. You actually have no guarantee that the first handler will get called prior to the others. So, even if you could fire one and not the other events, you could not depend upon the order in which they are called.

You will need to do the check prior to firing the event.


You can't stop the execution of the events. Simply put the check in front of the data query function, so it gets called whenever data is requested.


It sounds like what you're probably looking for is more along the lines of a mutex than a flag. I don't believe you can explicitly define the order of handled events.


have another flag which determines a false condition and if so, dont let the method be executed, also have the flag changed to true whenever a textbox etc is updated

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜