handlers

call an eventhandler with arguments

江枫思渺然 提交于 2019-12-03 05:47:23
Visual Studio 2008, C# 3.0. I have a method below which calls an event handler. I would like to pass the two arguments received by the method to the event handler. I would like to do something like this: wc.DownloadDataCompleted += wc.DownloadedDataCompleted(strtitle, placeid); Is this even possible, if yes, how would I go about doing it ? Code Snippet: public void downloadphoto(string struri,string strtitle,string placeid) { using (WebClient wc = new WebClient()) { wc.DownloadDataCompleted += wc_DownloadDataCompleted; wc.DownloadDataAsync(new Uri(struri)); } } The easiest way to do this is to

Custom EventHandler vs. EventHandler<EventArgs>

萝らか妹 提交于 2019-12-03 01:47:23
问题 Recently I've been wondering if there is any significant difference between this code: public event EventHandler<MyEventArgs> SomeEvent; And this one: public delegate void MyEventHandler(object sender, MyEventArgs e); public event MyEventHandler SomeEvent; They both do the same thing and I haven't been able to tell any difference. Although I've noticed that most classes of the .NET Framework use a custom event handler delegate for their events. Is there a specific reason for this? 回答1: You're

gwt problem with HandlerRegistration

北城以北 提交于 2019-12-02 21:26:10
问题 I have a problem. I have a map and added ClickHandler, but after pushing a button I want to remove it. I know that there's some HandlerRegistration but I don't know how to use it. part of my code: map.addMapClickHandler(new MapClickHandler() { public void onClick(MapClickEvent e) { ... } }); can anyone help me? 回答1: MapWidget#addMapClickHandler() doesn't return a HandlerRegistration, but the MapWidget class defines a removeMapClickHandler() method: map.addMapClickHandler(new MapClickHandler()

Serve javascript file via http Handler

守給你的承諾、 提交于 2019-12-02 20:02:32
问题 I've written a HTTP Handler that outputs content depending on values passed to the handler. I am trying to extend it so that it outputs flash aswell, however to do so I need to also serve a javascript file. The javascript file itself is an embedded resource in another assembly, so I am trying the following: public void ProcessRequest(HttpContext context) { ((System.Web.UI.Page)context.CurrentHandler).ClientScript.RegisterClientScriptInclude("swfobject", ((System.Web.UI.Page)context

The logging.handlers: How to rollover after time or maxBytes?

﹥>﹥吖頭↗ 提交于 2019-12-02 19:27:56
I do struggle with the logging a bit. I'd like to roll over the logs after certain period of time and also after reaching certain size. Rollover after a period of time is made by TimedRotatingFileHandler , and rollover after reaching certain log size is made by RotatingFileHandler . But the TimedRotatingFileHandler doesn't have the attribute maxBytes and the RotatingFileHandler can not rotate after a certain period of time. I also tried to add both handlers to logger, but the result was doubled logging. Do I miss something? I also looked into source code of logging.handlers . I tried to

Custom EventHandler vs. EventHandler<EventArgs>

杀马特。学长 韩版系。学妹 提交于 2019-12-02 15:21:47
Recently I've been wondering if there is any significant difference between this code: public event EventHandler<MyEventArgs> SomeEvent; And this one: public delegate void MyEventHandler(object sender, MyEventArgs e); public event MyEventHandler SomeEvent; They both do the same thing and I haven't been able to tell any difference. Although I've noticed that most classes of the .NET Framework use a custom event handler delegate for their events. Is there a specific reason for this? You're right; they do the same thing. Thus, you should probably prefer the former over the latter because it's

Serve javascript file via http Handler

青春壹個敷衍的年華 提交于 2019-12-02 07:54:34
I've written a HTTP Handler that outputs content depending on values passed to the handler. I am trying to extend it so that it outputs flash aswell, however to do so I need to also serve a javascript file. The javascript file itself is an embedded resource in another assembly, so I am trying the following: public void ProcessRequest(HttpContext context) { ((System.Web.UI.Page)context.CurrentHandler).ClientScript.RegisterClientScriptInclude("swfobject", ((System.Web.UI.Page)context.CurrentHandler).ClientScript.GetWebResourceUrl(typeof(MyAssembly.Load), "MyResourceAssembly.swfobject.js"));

Disable user interaction in a GWT container?

China☆狼群 提交于 2019-12-01 13:16:59
I want to disable/enable user interaction (mouse click more specificly) on many widgets like hyperlink, button, etc which are contained in a composite (flextable) there are more than one click handlers, and I don't want to bother with removing and adding listeners according to mode (interaction enabled/disabled) Any ideas would be appriciated... You forgot to mention the version of GWT. In GWT 2.0 you can use this code snippet or something similar. This feature allows you to cancel events before they are handed over to the target widget. Event.addNativePreviewHandler(new Event

Disable user interaction in a GWT container?

我怕爱的太早我们不能终老 提交于 2019-12-01 11:30:31
问题 I want to disable/enable user interaction (mouse click more specificly) on many widgets like hyperlink, button, etc which are contained in a composite (flextable) there are more than one click handlers, and I don't want to bother with removing and adding listeners according to mode (interaction enabled/disabled) Any ideas would be appriciated... 回答1: You forgot to mention the version of GWT. In GWT 2.0 you can use this code snippet or something similar. This feature allows you to cancel

Tornado Restful Handler Classes

ⅰ亾dé卋堺 提交于 2019-11-30 11:27:15
问题 I've read around and found this answered question about a problem relating to this but what I really want to know is how to implement this structure and how many handler classes I need: 1 GET /items #=> index 2 GET /items/1 #=> show 3 GET /items/new #=> new 4 GET /items/1/edit #=> edit 5 PUT /items/1 #=> update 6 POST /items #=> create 7 DELETE /items/1 #=> destroy I was thinking having 2,5,7 mapped to a single handler routed to /items/[0-9]+ and having 3 new handlers for the items, items/new