Search Results

Search found 10381 results on 416 pages for 'delegate and events'.

Page 112/416 | < Previous Page | 108 109 110 111 112 113 114 115 116 117 118 119  | Next Page >

  • jQuery responds to click() differently for user and programmatic triggers

    - by Moss
    Here's the code: this.Form.find("input[type=checkbox]").click(function(event) { if ($(this).is(":checked")) { console.log("checked"); } else { console.log("unchecked"); } }); If the checkbox is not checked, and I click with the mouse, I get "checked". If I trigger it programmatically like $("#someCheckbox").click(), I get "unchecked". How to make the two behave the same way?

    Read the article

  • Calling function from an object with event listener

    - by Mirat Can Bayrak
    i have a view model something like this: CANVAS = getElementById... RemixView = function(attrs) { this.model = attrs.model; this.dragging = false; this.init(); }; RemixView.prototype = { init: function() { CANVAS.addEventListener("click", this.handleClick); }, handleClick: function(ev) { var obj = this.getHoveredObject(ev); }, getHoveredObject: function(ev) {} ... ... } rv = new RemixView() the problem is my when clickHandler event fired, this object is being equal to CANVAS object, not RemixView. So i get error that says: this.getHoveredObject is not a function What is correct approach at that stuation?

    Read the article

  • Detect if the iframe content has loaded successfully.

    - by skinssay
    Hi, I have a widget that contains an iframe. The user can configure the url of this iframe, but if the url could not be loaded (it does not exists or the user does not have access to internet) then the iframe should failover to a default offline page. The question is, how can I detect if the iframe could be loaded or not? I tried subscribing to the 'load' event, and, if this event is not fired after some time then I failover, but this only works in Firefox, since IE and Chrome fires the 'load' event when the "Page Not Found" is displayed.

    Read the article

  • ASP.net PreInit() Vs Init()

    - by ASP.netBeginner
    From local forum i understood that PreInit can be used to handle the following PreInit() >Master pages can be called dynamically >Themes can be set dynamically >Programatically add controls to controls collection and i read Init() is for Init() In this event, we can read the controls properties (set at design time). We cannot read control values changed by the user because that changed value will get loaded after LoadPostData() event fires. Question I am not getting the point "We cannot read control values changed by the user".Where do users change the value of control?.Example would help me to understand the point.

    Read the article

  • How can I define a one-time event so that new handlers fire (once) even after the event has already occurred?

    - by harpo
    You know how this $(function() { ... }); will fire whether or not the "document ready" event has already occurred? I want to define an event like that. That event is a special case in jQuery. I'm wondering if a custom event can behave in the same way, using only the standard event mechanisms. Ideally, I'd like to be able to define handlers in the "normal" way: $(document).on("init.mything", function() { ... }); This works now if the above runs before init.mything is triggered. But if it doesn't, then the handler never runs. What makes this tricky is, I don't want to assume anything except that jQuery has loaded. Any ideas?

    Read the article

  • How to perform .select() on jQuery masked text input

    - by dllhell
    I'm using http://digitalbush.com/projects/masked-input-plugin/ plugin. There is an input text with defined mask: <input type="text" id="txtMyInput" class="FocusSense"/> and a script: $(document).ready(function () { jQuery(function ($) { $("#txtMyInput").mask("?9.99"); }); $(".FocusSense").focus(function () { this.select(); }); }) As you can see, I would like select all in txtMyInput on focus but but alas! On focus, mask appears and loose .select(). What should I do to preserve mask and .select()?

    Read the article

  • How could I click in a control and drag (not Drag and Drop) out of it but still follow the event as

    - by Jelly Amma
    Hello, I would like to allow the user to click within my UserControl and drag left/right to zoom in/out but I'd like the dragging not to be restricted to the actual control's boundaries. What sort of event or strategy would be the right way to track the mouse position outside the control and the form until the mouse click is released ? Thanks in advance for any help or advice.

    Read the article

  • Column moved [finished] event in JTable

    - by chown
    How should I detect that column moved action is finished in JTable? I've added columnModeListener to my column model but the problem is columnMoved method is called every time a column moves (by certain pixels). I don't want this behavior. I just want to detect when the column dragging is finished. columnModel.addColumnModelListener(new TableColumnModelListener() { public void columnAdded(TableColumnModelEvent e) { } public void columnRemoved(TableColumnModelEvent e) { } public void columnMoved(TableColumnModelEvent e) { //this is called so many times //I don't want this, but something like column moved finished event System.out.println("Moved "+e.getFromIndex()+", "+e.getToIndex()); } public void columnMarginChanged(ChangeEvent e) { } public void columnSelectionChanged(ListSelectionEvent e) { } }); I hope it is clear what I'm looking for. Thanks.

    Read the article

  • about event handle-function in JavaScript

    - by T_t
    hi! In my program,i write like this: function handleFuc( event ){ var a = event.pageX; var b = event.pageY; var tempdiv = document.createElement("div"); tempdiv.onmouseout = function(){ var x = event.pageX; // 1 var y = event.pageY; // } } var div = document.getElementById( "id" ); div.onmouseover = function(){ handleFuc( event ); } now,in function handleFuc, how could i distinguish the two "event"? Thanks! :)

    Read the article

  • Adding image to html markup

    - by user1491991
    Hello guys i'm having a problem appending a image to my html markup which is generated when a button is clicked... wondering if i could some dirction __--------------------------SCRIPT----------------------------------------------------------- (function($){ $.confirm = function(params){ if($('#confirmOverlay').length){ // A confirm is already shown on the page: return false; } var buttonHTML = ''; $.each(params.buttons,function(name,obj){ // Generating the markup for the buttons: buttonHTML += '<a href="#" class="button '+obj['class']+'">'+name+'<span></span></a>'; if(!obj.action){ obj.action = function(){}; } }); var closetext= 'close'; var markup = [ '<div id="confirmOverlay">', '<div id ="model">','<div id="confirmBox">', '<div id="header">','<div id ="title">',params.title,'</div>', '<div id="close">','<ol id = "olclose">','<li id = "liclose">','<a id="close" href = "#">',closetext,'</a></li>', '<li id = "liclose">','<a id="close" href = "#">','<img src="../modal-close.gif"/>','</a></li>','</ol></div></div>', '<div id ="textbox">','<p>',params.message,'<br>','<br>' ,buttonHTML,'</p>', '</div>', '</div></div></div></div>' ].join(''); $(markup).hide().appendTo('body').fadeIn(); var buttons = $('#confirmBox .button'), i = 0; $.each(params.buttons,function(name,obj){ buttons.eq(i++).click(function(){ // Calling the action attribute when a // click occurs, and hiding the confirm. obj.action(); $.confirm.hide(); return false; }); }); } $.confirm.hide = function(){ $('#confirmOverlay').fadeOut(function(){ $(this).remove(); }); } })(jQuery); i've used firebug to check and its unable to fetch the image here

    Read the article

  • jQuery: How do I insert an html string an arbitrary number of times (i.e. not with an each() function)?

    - by Sam Bivins
    I just need to take a certain html query object and append it to an html element a lot of times. I have this: var box = $("<div class='box'>&nbsp</div>"); $("#firstbox").after(box); and it works fine, but it just adds one 'box' after the #firstbox element. I'd like to do something like this: var box = $("<div class='box'>&nbsp</div>"); $("#firstbox").after(box * 6000); so that it will insert 6000 copies of that 'box' html, but this is not working. This is I'm sure the easiest thing to do, but I can't seem to find how to multiply actions like this without using the each() function, which doesn't apply here because I don't have 6000 of anything on my page. Thanks.

    Read the article

  • Windows setevent processsing

    - by Waldorf
    I wonder how setevent is handled internally within Windows. I have the following situation Std::thread thread loop which executes while std::atomic == true Inside the loop is a waitforsingleObject which sleeps infinite in alertable state. A function stopThread() which does the following: - Clears the atomic bool - Calls Setevent on the event object - Calls thread.join This often hangs, I get the impression that setevent has still some work to do in the current thread, while join blocks the current thread. If I add an additional Boolean in the thread which is set after waitforsinlgleObject and I wait for this to be set before calling join() Everything seems to work ok. Code (error checking omitted here) Init code/declarations: HANDLE m_WakeupThreadEvent; std::atomic<bool> m_ReceiverEnabled; m_WakeupThreadEvent = CreateEvent(NULL, false, false, "RxThreadWakeupEvent" ); Thread code: while(m_ReceiverEnabled) { DWORD rslt = WaitForSingleObjectEx(m_WakeupThreadEvent, INFINITE, true); // Here some checking for rslt; } function code: m_ReceiverEnabled = true; SetEvent( m_WakeupThreadEvent ) m_Thread.join() Is there some explanation for this behavior ? I could not find any details about the operation of setEvent()

    Read the article

  • Java. What to do with Choice()???

    - by modzo
    import java.awt.*; import java.awt.event.*; import java.applet.*; public class ChoiceSample extends Applet implements ActionListener, ItemListener { Choice dz2; public void init(){ dz2 = new Choice(); dz2.addItem("female"); dz2.addItem("male"); dz2.addItemListener(this); add(dz2); public void itemStateChanged(ItemEvent e) { String result = dz2.getSelectedItem(); repaint(); if(result.equals(getParameter("male"))){ dz1 = 0.5; } else{ dz1 = 0.7; } } } /* this is yust a fragment from my program but this is the only thing that I can`t make right. I need when I chose male - dz1 = 0.5, but when I chose female dz1 = 0.7 Can someone help me, please? */

    Read the article

  • Novell eDirectory—How can I aggregate account lockout events?

    - by bshacklett
    I'm seeing an account become locked out pretty frequently and I wanted to pull an aggregated log together of all of the lockout events so I could get a better idea of what times it's occurring. Normally I'd do this with EventCombMT.exe, but I'm in a Novell environment at the moment. Is there a Novell equivalent to Microsoft's ALTools or another diagnostic utility I could use to help aggregate lockout events into an easy to read log file?

    Read the article

  • proper way to dynamically assign backbone.js view el

    - by kikuchiyo
    I would like to create two ( or more ) view instances, each with different el attributes, and have events bound to them via backbone.js view's events hash ( not through jQuery ). Getting events to trigger when all instantiations have the same el is easy: someView = Backbone.View.extend({ el: '#someDiv', events: { 'click': 'someFunction' }, someFunction: function(){ //Do something here } }); So far, if I assign el in the initialize function, and set events normally as follows, events do not trigger: someView = Backbone.View.extend({ events: { 'click': 'someFunction' }, initialize: function( options ){ this.el = options.el }, someFunction: function(){ //Do something here } }); My first instinct was to have el be a function that returns the string representation of the dom element of interest: someView = Backbone.View.extend({ el: function(){ return '#someDiv-' + this.someNumber }, events: { 'click': 'someFunction' }, initialize: function( options ){ this.someNumber = options.someNumber }, someFunction: function(){ //Do something here } }); However, this triggers someFunction x times if I have x instantiations of someView. Next I tried setting both the el and events attributes in initialize: someView = Backbone.View.extend({ initialize: function( options ){ this.el = options.el this.events = { 'click': 'someFunction' } }, someFunction: function(){ //Do something here } }); but this does not trigger events. At this point I'm pretty much fishing. Does anyone know how instantiate a backbone.js view with an el specific to that instance that has events that only trigger for that instance, and not other instances of the View?

    Read the article

  • How much should the AppDelegate do?

    - by Rudiger
    I'm designing quite a large App and on startup it will create sessions with a few different servers. As they are creating a session which is used across all parts of the app its something I thought would be best in App Delegate. But the problem is I need the session progress to be represented on the screen. I plan to have a UIToolBar at the bottom of the main menu which I don't want to cover with the progress bar but cover the UIView above it.So the way I see it I could do it a few different ways. 1) Have the App Delegate establish the sessions and report the progress to the main menu class so it can represent it in the progress bar (will I have any issues doing this if the sessions are created in a separate thread?), 2) have the App delegate display the main menu (UIView with a bunch of buttons and UIToolBar) and have it track and display the progress (I have never displayed anything in the App Delegate but assume you can do this but its not recommended) or 3) have the App Delegate just push the main menu and have the mainMenu class create the sessions and display the progress bar. 4) I think the other way to do it is to create the sessions in a delegate class and have the delegate set to mainMenu rather than self (AppDelegate), although I've never used anything other then self so not sure if this will work or if I will be able to close the thread (through calling super maybe?) as its running in the AppDelegate rather than the delegate of the class. As I've kinda said before the sessions are being created in a class in a separate thread so it wont lock the UI and I think the best way is the first but am I going to have issues having it running in a separate thread, reporting back to the app delegate and then sending that message to the mainMenu view? I hope that all makes sense, let me know if you need any further clarification. Any information is appreciated Cheers,

    Read the article

  • How do I tell if an action is a lambda expression?

    - by Keith
    I am using the EventAgregator pattern to subscribe and publish events. If a user subscribes to the event using a lambda expression, they must use a strong reference, not a weak reference, otherwise the expression can be garbage collected before the publish will execute. I wanted to add a simple check in the DelegateReference so that if a programmer passes in a lambda expression and is using a weak reference, that I throw an argument exception. This is to help "police" the code. Example: eventAggregator.GetEvent<RuleScheduler.JobExecutedEvent>().Subscribe ( e => resetEvent.Set(), ThreadOption.PublisherThread, false, // filter event, only interested in the job that this object started e => e.Value1.JobDetail.Name == jobName ); public DelegateReference(Delegate @delegate, bool keepReferenceAlive) { if (@delegate == null) throw new ArgumentNullException("delegate"); if (keepReferenceAlive) { this._delegate = @delegate; } else { //TODO: throw exception if target is a lambda expression _weakReference = new WeakReference(@delegate.Target); _method = @delegate.Method; _delegateType = @delegate.GetType(); } } any ideas? I thought I could check for @delegate.Method.IsStatic but I don't believe that works... (is every lambda expression a static?)

    Read the article

  • How to have LiveJournal delegate my OpenID to something else?

    - by T-Boy
    I understand that if I have full control over my domain, I can set it up so that I can delegate the task of authenticating to another OpenID service provider. The problem is, what I'd like to do is to get the LiveJournal server to pass the authentication to someone else, instead of having LJ doing it. Preferably what I'd like to do is get LiveJournal, when asked by a web site, say, "No, I don't do it anymore -- go to this address". The plan was that this address would then be in a domain I fully control, which then would pass it on to whichever service provider I choose. I don't even know if I've gotten my understanding of OpenID right, if all this shenanigans are necessary, if my question makes sense, or if it's even possible with a service provider like Livejournal. ETA: Doing a little more reading up, and examining the source for my LiveJournal user page, I note that this particular line in the file's <header> area: <link rel="openid.server" href="http://www.livejournal.com/openid/server.bml" /> I suspect that changing this will allow me to forward OpenID requests to whomever I wish, I think; so far so good. Now comes the hard part -- figuring out how to change all of that using LiveJournal's customization options, if that is at all possible (here's hoping I don't need to pay to get that functionality).

    Read the article

  • Extreme Optimization – Numerical Algorithm Support

    - by JoshReuben
    Function Delegates Many calculations involve the repeated evaluation of one or more user-supplied functions eg Numerical integration. The EO MathLib provides delegate types for common function signatures and the FunctionFactory class can generate new delegates from existing ones. RealFunction delegate - takes one Double parameter – can encapsulate most of the static methods of the System.Math class, as well as the classes in the Extreme.Mathematics.SpecialFunctions namespace: var sin = new RealFunction(Math.Sin); var result = sin(1); BivariateRealFunction delegate - takes two Double parameters: var atan2 = new BivariateRealFunction (Math.Atan2); var result = atan2(1, 2); TrivariateRealFunction delegate – represents a function takes three Double arguments ParameterizedRealFunction delegate - represents a function taking one Integer and one Double argument that returns a real number. The Pow method implements such a function, but the arguments need order re-arrangement: static double Power(int exponent, double x) { return ElementaryFunctions.Pow(x, exponent); } ... var power = new ParameterizedRealFunction(Power); var result = power(6, 3.2); A ComplexFunction delegate - represents a function that takes an Extreme.Mathematics.DoubleComplex argument and also returns a complex number. MultivariateRealFunction delegate - represents a function that takes an Extreme.Mathematics.LinearAlgebra.Vector argument and returns a real number. MultivariateVectorFunction delegate - represents a function that takes a Vector argument and returns a Vector. FastMultivariateVectorFunction delegate - represents a function that takes an input Vector argument and an output Matrix argument – avoiding object construction  The FunctionFactory class RealFromBivariateRealFunction and RealFromParameterizedRealFunction helper methods - transform BivariateRealFunction or a ParameterizedRealFunction into a RealFunction delegate by fixing one of the arguments, and treating this as a new function of a single argument. var tenthPower = FunctionFactory.RealFromParameterizedRealFunction(power, 10); var result = tenthPower(x); Note: There is no direct way to do this programmatically in C# - in F# you have partial value functions where you supply a subset of the arguments (as a travelling closure) that the function expects. When you omit arguments, F# generates a new function that holds onto/remembers the arguments you passed in and "waits" for the other parameters to be supplied. let sumVals x y = x + y     let sumX = sumVals 10     // Note: no 2nd param supplied.     // sumX is a new function generated from partially applied sumVals.     // ie "sumX is a partial application of sumVals." let sum = sumX 20     // Invokes sumX, passing in expected int (parameter y from original)  val sumVals : int -> int -> int val sumX : (int -> int) val sum : int = 30 RealFunctionsToVectorFunction and RealFunctionsToFastVectorFunction helper methods - combines an array of delegates returning a real number or a vector into vector or matrix functions. The resulting vector function returns a vector whose components are the function values of the delegates in the array. var funcVector = FunctionFactory.RealFunctionsToVectorFunction(     new MultivariateRealFunction(myFunc1),     new MultivariateRealFunction(myFunc2));  The IterativeAlgorithm<T> abstract base class Iterative algorithms are common in numerical computing - a method is executed repeatedly until a certain condition is reached, approximating the result of a calculation with increasing accuracy until a certain threshold is reached. If the desired accuracy is achieved, the algorithm is said to converge. This base class is derived by many classes in the Extreme.Mathematics.EquationSolvers and Extreme.Mathematics.Optimization namespaces, as well as the ManagedIterativeAlgorithm class which contains a driver method that manages the iteration process.  The ConvergenceTest abstract base class This class is used to specify algorithm Termination , convergence and results - calculates an estimate for the error, and signals termination of the algorithm when the error is below a specified tolerance. Termination Criteria - specify the success condition as the difference between some quantity and its actual value is within a certain tolerance – 2 ways: absolute error - difference between the result and the actual value. relative error is the difference between the result and the actual value relative to the size of the result. Tolerance property - specify trade-off between accuracy and execution time. The lower the tolerance, the longer it will take for the algorithm to obtain a result within that tolerance. Most algorithms in the EO NumLib have a default value of MachineConstants.SqrtEpsilon - gives slightly less than 8 digits of accuracy. ConvergenceCriterion property - specify under what condition the algorithm is assumed to converge. Using the ConvergenceCriterion enum: WithinAbsoluteTolerance / WithinRelativeTolerance / WithinAnyTolerance / NumberOfIterations Active property - selectively ignore certain convergence tests Error property - returns the estimated error after a run MaxIterations / MaxEvaluations properties - Other Termination Criteria - If the algorithm cannot achieve the desired accuracy, the algorithm still has to end – according to an absolute boundary. Status property - indicates how the algorithm terminated - the AlgorithmStatus enum values:NoResult / Busy / Converged (ended normally - The desired accuracy has been achieved) / IterationLimitExceeded / EvaluationLimitExceeded / RoundOffError / BadFunction / Divergent / ConvergedToFalseSolution. After the iteration terminates, the Status should be inspected to verify that the algorithm terminated normally. Alternatively, you can set the ThrowExceptionOnFailure to true. Result property - returns the result of the algorithm. This property contains the best available estimate, even if the desired accuracy was not obtained. IterationsNeeded / EvaluationsNeeded properties - returns the number of iterations required to obtain the result, number of function evaluations.  Concrete Types of Convergence Test classes SimpleConvergenceTest class - test if a value is close to zero or very small compared to another value. VectorConvergenceTest class - test convergence of vectors. This class has two additional properties. The Norm property specifies which norm is to be used when calculating the size of the vector - the VectorConvergenceNorm enum values: EuclidianNorm / Maximum / SumOfAbsoluteValues. The ErrorMeasure property specifies how the error is to be measured – VectorConvergenceErrorMeasure enum values: Norm / Componentwise ConvergenceTestCollection class - represent a combination of tests. The Quantifier property is a ConvergenceTestQuantifier enum that specifies how the tests in the collection are to be combined: Any / All  The AlgorithmHelper Class inherits from IterativeAlgorithm<T> and exposes two methods for convergence testing. IsValueWithinTolerance<T> method - determines whether a value is close to another value to within an algorithm's requested tolerance. IsIntervalWithinTolerance<T> method - determines whether an interval is within an algorithm's requested tolerance.

    Read the article

  • Sync Google Calendar with SharePoint Calendar

    - by dataintegration
    The ADO.NET Providers for Google and SharePoint make it easy to retrieve and update data in both Google's web services and SharePoint. This article shows how the SQL interface to data makes it easy to build applications that need to move data from one source to another. The application described here is a demo Windows application that synchronizes calendar events between Google and SharePoint, but the RSSBus Providers can be used to achieve integrations on both the .NET and the Java platforms, including more sophisticated features like full automation. Getting the Events Step 1: Google accounts can have several calendars. Obtain a list of a user's Google Calendars by issuing a query to the Calendars table. For example: SELECT * FROM Calendars. Step 2: In order to get a list of the events from a given Google Calendar, issue a query to the CalendarEvents table while specifying the CalendarId from the Calendars table. The resulting events can be further filtered by using the StartDateTime or EndDateTime columns. For example: SELECT * FROM CalendarEvents WHERE (CalendarId = '[email protected]') AND (StartDateTime >= '1/1/2012') AND (StartDateTime <= '2/1/2012') Step 3: SharePoint stores data in Lists. There are various types of lists, e.g., document lists and calendar lists. A SharePoint account can have several lists of the same type. To find all the calendar lists in SharePoint, use the ListLists stored procedure and inspect the BaseTemplate column. Step 4: The SharePoint data provider models each SharPoint list as a table. Get the events in a particular calendar by querying the table with the same name as the list. The events may be filtered further by specifying the EventDate or EndDate columns. For example: SELECT * FROM Calendar WHERE (EventDate >= '1/1/2012') AND (EventDate <= '2/1/2012') Synchronizing the Events Synchronizing the events is a simple process. Once the events from Google and SharePoint are available they can be compared and synchronized based on user preference. The sample application does this based on user input, but it is easy to create one that does the synchronization automatically. The INSERT, UPDATE, and DELETE statements available in both data providers makes it easy to create, update, or delete events as needed. Pre-Built Demo Application The executable for the demo application can be downloaded here. Note that this demo is built using BETA builds of the ADO.NET Provider for Google V2 and ADO.NET Provider for SharePoint V2, and will expire in 2013. Source Code You can download the full source of the demo application here. You will need the Google ADO.NET Data Provider V2 and the SharePoint ADO.NET Data Provider V2, which can be obtained here.

    Read the article

  • How to use delegate to perform callback between caller and web service helper class?

    - by codemonkie
    I have 2 classes A and B, where they belongs to the same namespace but resides in seperate files namely a.cs and b.cs, where class B essentially is a helper wrapping a web service call as follow: public class A { public A() // constructor { protected static B b = new B(); } private void processResult1(string result) { // come here when result is successful } private void processResult2(string result) { // come here when result is failed } static void main() { b.DoJobHelper(...); } } public class B { private com.nowhere.somewebservice ws; public B() { this.ws = new com.nowhere.somewebservice(); ws.JobCompleted += new JobCompletedEventHandler(OnCompleted); } void OnCompleted(object sender, JobCompletedEventArgs e) { string s = e.Result; Guid taskID = (Guid)e.UserState; switch (s) { case "Success": // Call processResult1(); break; case "Failed": // Call processResult2(); break; default: break; } } public void DoJobHelper() { Object userState = Guid.NewGuid(); ws.DoJob(..., userState); } } (1) I have seen texts on the net on using delegates for callbacks but failed to apply that to my case. All I want to do is to call the appropriate processResult() method upon OnCompleted() event, but dunno how to and where to declare the delegate: public delegate void CallBack(string s); (2) There is a sender object passed in to OnCompleted() but never used, did I miss anything there? Or how can I make good use of sender? Any helps appreciated.

    Read the article

  • [C#] How to use delegate to perform callback between caller and web service helper class?

    - by codemonkie
    I have 2 classes A and B, where they belongs to the same namespace but resides in seperate files namely a.cs and b.cs, where class B essentially is a helper wrapping a web service call as follow: public class A { public A() // constructor { protected static B b = new B(); } private void processResult1(string result) { // come here when result is successful } private void processResult2(string result) { // come here when result is failed } static void main() { b.DoJobHelper(...); } } public class B { private com.nowhere.somewebservice ws; public B() { this.ws = new com.nowhere.somewebservice(); ws.JobCompleted += new JobCompletedEventHandler(OnCompleted); } void OnCompleted(object sender, JobCompletedEventArgs e) { string s; Guid taskID = (Guid)e.UserState; switch (s) { case "Success": // Call processResult1(); break; case "Failed": // Call processResult2(); break; default: break; } } public void DoJobHelper() { Object userState = Guid.NewGuid(); ws.DoJob(..., userState); } } (1) I have seen texts on the net on using delegates for callbacks but failed to apply that to my case. All I want to do is to call the appropriate processResult() method upon OnCompleted() event, but dunno how to and where to declare the delegate: public delegate void CallBack(string s); (2) There is a sender object passed in to OnCompleted() but never used, did I miss anything there? Or how can I make good use of sender? Any helps appreciated.

    Read the article

< Previous Page | 108 109 110 111 112 113 114 115 116 117 118 119  | Next Page >