AddEventListener - creating an async method?

Hello. Beginner question.
I have an edit-able DataGrid which is populated by an
ArrayCollection. There is an Event Listener on the ArrayCollection.
When a user edits a field in the DataGrid, the Event Listener
calculates the sum of all of the items in a row - and displays it
in a Label field beside the row.
The issue is performance. Performance isn't great when i go
from one DataGrid cell to the next, so I'm trying to speed things
up a bit. So one thought is to modify the code so that the
transition to the next cell isn't dependent on the calculation
completing...
So how do I do this? (or doesn't this idea make sense?)
Secondly, anything else i should be looking at to improve
performance?
any assistance is greatly appreciated. thanks for your time.
chris

quick update. i found the main source of the performance
issue. the event listener was doing more than just calculating the
sum. it was essentially repopulating the grid every time an edit
was made. so i removed that event listener at the appropriate time
and things are considerably better.
so there's just the other question - although the more i
think about it, i'm not sure it's a legit question. when something
fires an event listener, it doesn't wait for the listener to
return, right? so it's already async. hmm, so yeah, i guess both
questions were bogus.
my apologies.
chris

Similar Messages

  • How to use multi async method in Windows Runtime Component (C#)

    I want to migrate an async method into Windows Runtime Component.
    CookieContainer cc = await utility.GetCookieContainer();
    But the content of async method still contains async methods.
    public async Task<CookieContainer> GetCookieContainer()
    if (stsAuthToken != null)
    if (DateTime.Now > stsAuthToken.Expires)
    this.stsAuthToken = await GetMsoStsSAMLToken();
    AuthCookies cookies = await GetAuthCookies(this.stsAuthToken);
    CookieContainer cc = new CookieContainer();
    Cookie samlAuthCookie = new Cookie("FedAuth", cookies.FedAuth)
    Path = "/",
    Expires = this.stsAuthToken.Expires,
    Secure = cookies.Host.Scheme.Equals("https"),
    HttpOnly = true,
    Domain = cookies.Host.Host
    cc.Add(this.spSiteUrl, samlAuthCookie);
    Cookie rtFACookie = new Cookie("rtFA", cookies.RtFA)
    Path = "/",
    Expires = this.stsAuthToken.Expires,
    Secure = cookies.Host.Scheme.Equals("https"),
    HttpOnly = true,
    Domain = cookies.Host.Host
    cc.Add(this.spSiteUrl, rtFACookie);
    this.cookieContainer = cc;
    And even GetMsoStsSAMLToken and GetAuthCookies contain async methods...
    How to migrate it?

    Hi Matt,
    I'm sorry for my unclear description.
    My WinRT Component is for Javascript. If I use folloiong codes, error occurs.
    public static async Task<bool> GetInternal(string url, string username, string password)
    bool r = await AuthUtility.Create(new Uri(url), username, password);
    return r;
    The error is
    SharePointWindowsRuntimeComponent.Common.GetInternal(System.String, System.String, System.String)' has a parameter of type 'System.Threading.Tasks.Task<System.Boolean>' in its signature. Although this generic type is not a valid Windows Runtime type,
    the type or its generic parameters implement interfaces that are valid Windows Runtime types.  Consider changing the type 'Task' in the method signature to one of the following types instead: Windows.Foundation.IAsyncAction, Windows.Foundation.IAsyncOperation,
    or one of the other Windows Runtime async interfaces. The standard .NET awaiter pattern also applies when consuming Windows Runtime async interfaces. Please see System.Runtime.InteropServices.WindowsRuntime.AsyncInfo for more information about converting managed
    task objects to Windows Runtime async interfaces.
    Some articles said, Task<T> is not WinRT type and should be converted to IAsyncOperation<T>. Only stirng, int, bool, object, array of above types and some 'simple' type can be used. (The
    related article)
    Then I try to convert Task<bool>, but the codes don't work.
    Above is why I ask this question.
    If async method can be used in WinRT component directly, please let me know why I got above error.
    Thanks.

  • SubmitGenerateReportAsync Issue. Await operator can only be used with Async Method

    Hi,
    I am trying to submit a request to download keyword performance report using following .
     var reportId =await SubmitGenerateReportAsync(reportRequest); its giving me error 
    The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
    Here is the SubmitGenerateReportAsync method. I am already using async in definition. Not sure what else is wrong.
     private async Task<string> SubmitGenerateReportAsync(ReportRequest report)
                var request = new SubmitGenerateReportRequest
                    ReportRequest = report
                return (await Service.CallAsync((s, r) => s.SubmitGenerateReportAsync(r), request)).ReportRequestId;
    Same issue with PollGenerateReportAsync
     reportStatus =await PollGenerateReportAsync(reportId.ToString());
      private async Task<ReportRequestStatus> PollGenerateReportAsync(string reportId)
                var request = new PollGenerateReportRequest
                    ReportRequestId = reportId
                return (await Service.CallAsync((s, r) => s.PollGenerateReportAsync(r), request)).ReportRequestStatus;
    Let me know if its easy fix.

    I fixed the link to our
    code example which shows how to run such a report from the console. You would create async methods, run, and wait from within Main.
    /// <summary>
    /// The entry point for the console application.
    /// </summary>
    /// <param name="args">Arguments are not required for this example.</param>
    public static void Main(string[] args)
    var example = new KeywordPerformance();
    Console.WriteLine(example.Description);
    try
    var authentication = new PasswordAuthentication(
    "<UserNameGoesHere>",
    "<PasswordGoesHere>");
    // The OAuthHelper class is available for download with the BingAdsExamples solution.
    // OAuthDesktopMobileImplicitGrant authentication = await OAuthHelper.AuthorizeImplicitly();
    var authorizationData = new AuthorizationData
    Authentication = authentication,
    CustomerId = <CustomerIdGoesHere>,
    AccountId = <AccountIdGoesHere>,
    DeveloperToken = "<DeveloperTokenGoesHere>"
    example.RunAsync(authorizationData).Wait();
    catch (Exception ex)
    Console.WriteLine(ex.Message);
    Best regards,
    Eric

  • Error while creating a overwrite method in class

    Hello.
    I'm trying to create an overwrite method in the class CL_HREIC_EECONTACT2SRCHV_IMPL but it just won't let me. Every time I try I get the message "The class has not yet been converted to the new class-local types" and I cannot create it.The thing is I've tried to create overwrite methods in diferent classes and sometimes I get the message and sometimes I don't, so it seems to depend on the class I'm trying to enhance, but I don't seem to be able to see any pattern in it.
    Any help?
    Thanks

    Hello i had the same problem and i couldn't create enhancement pre or post methods.
    The message was:
    The class has not yet been converted to the new class-local types
    Exception of class CX_ENH_OLD_LOCAL_CLASS_TYPES
    This can be fixed by entering in SE24 transaction: Change class. From menu choose: Utilities -> Convert class-local types.
    After that activate the class.
    Now the class can be enhanced.
    However this action requires change of the class
    Regards,
    Rosen

  • How to create the custom method and make it available to clients:

    Hello, Can any one help me with this problem ASAP??
    I am trying to work on an example of "Customizing the Query and Creating an Associated Custom Method"
    from http://helponline.oracle.com/jdeveloper/help/topics/jdeveloper/developing_mvc_applications/adf_pviewcustommethod.html?tp=true#method. To do that, the first task is to create the custom method and make it available to clients.
    Following instructions in the helponline documentation, I completed the three steps: (1) "Specify a custom query for the View Object definition for EmployeesView", (2) "Add the custom method to the application module Java class", and (3) "Make the method available to clients".
    The following is the error message I got to test the application module. Can anyone tell me what the message really means and what I should do. I am wondering if there is any mistakes in the document.
    (oracle.jbo.SQLStmtException) JBO-27122: SQL error during statement preparation. Statement: SELECT Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE, Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Employees.DEPARTMENT_ID FROM EMPLOYEES Employees WHERE Employees.SALARY > :1 and Employees.DEPARTMENT_ID = :2
    ----- LEVEL 1: DETAIL 0 -----
    (java.sql.SQLException) ORA-01008: not all variables bound

    You need to set values for the parameters in your query before you try to execute the query in the view object.
    So you need to call the setBindVars method before the query.

  • Creating a new method in an enhanced component class implemetation

    Hello Experts,
    I am trying to create a new method in the enhanced component(BT115IT_SLSO) implementation class ( ZL_BT115IT__ITEMS_IMPL)to run our custom functionality. But somehow when I put a breakpoint and debug while I add a product to the sales order the method doesnt get trigerred.
    Is there some thing which I have to do  get this trigerred ? I just added a ned method and placed some custom code in it. Do I have to invoke it anywhere ?
    Pls help me out. I am new to Web UI.
    Thanks

    Hi Mavrick,
    As you are performing some action like item addition , there you need a method called as " event handler " to handle the event and perform the required actions.
    Place a break point in DO_HANDLE_EVENT method , and you will know the exact event handler method which is getting triggered . or if you are defining a new event ( by adding any new button) you should create a event handler method using wizard giving the same name which is defined on_click field of the button as it is case sensitive.
    Regards,
    Nithish

  • View not copied or enhanced with wizard Error while creating Event Handler method in Z Component

    Hello Friends,
    In one Z Component (Custom Component), in one of the views, while creating event handler, it gave me error message that view not copied or enhanced with wizard.
    I am aware that in Standard Component, if we want to create the event handler method then we need to first Enhance the Component and then we need to enhance the view.
    But, in the Z Component (Custom Component), how to create event handler method in one of the views as while creating event handler method i am getting view not copied or enhanced with wizard error.

    Hi,
    Add a method in views impl class with naming convention eh_on__* with htmt and html_ex parameters.  I dont have have the system right now. Please check any existing event import export parameters.
    Check out do handle event method in the same class.
    Redefine that method.  Call that event method in this handle method. See existing code for reference.
    Attach that event to the button on click event in .htm page.
    Regards,
    Bhushan

  • Creating Properties and Methods for an exe built in LabVIEW

    Hi all,
    How do we create properties and methods for an executable built in LabVIEW.
    I know when building an exe, the "Enable ActiveX server" option in advanced has to be enabled.
    But after that how do we create Properties and methods for the activeX component.
    Your help is greatly appreciated.
    Regards,
    Muthuraman S
    Regards,
    Muthuraman

    You cannot build your own COM specific properties and methods for the ActiveX interface in LabVIEW, the only thing exposed are the normal VI server properties and methods.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Garbage collection of objects created inside a method

    I have method and inside the method I create new Objects I mean I instantiate objects using new and call some methods on these objects.
    once the method execution is completed and control goes to caller of the method will all the object created inside the method will be garbage collected ?
    here with code
               public List<StgAuditGeneral> getAudits(
              List<StgAuditGeneral>  audits= new ArrayList<StgAuditGeneral>();
                  for(Map<String, String> result :results ){
                   audits.add(new MapToObject<StgAuditGeneral>() {
                        @Override
                        public StgAuditGeneral getObject() {
                                             StgAuditGeneral  stg= new StgAuditGeneral();
                             return stg;
                   }.getObject());
              }in the above method I cam creating tons of objects wil they be garbage collected immediatedly after jvm leaves the method ?

    user11138293 wrote:
    I have method and inside the method I create new Objects I mean I instantiate objects using new and call some methods on these objects.
    once the method execution is completed and control goes to caller of the method will all the object created inside the method will be garbage collected ?If there are no reachable references, to those objects, then when the method ends, they become eligible for GC. If and when they are actually collected is something we can't know or control, and generally don't care about. The only guarantee is that everything that can be collected will be collected before an OutOfMemoryError is thrown. So from our perspective, once it's eligible for collection, it is effectively collected.
    If you pass references to those objects to something else that holds onto them after the method ends, then they are still reachable, and not eligible for collection.
    However, you almost never need to even think about whether something is eligible for GC or not. It works pretty intuitively.

  • How to create an init method with executeEmptyRowSet() in task flow

    hi i try this <method-call id="Empty">
    <method>executeEmptyRowSet()</method>
    </method-call> in my task flow but am geting error
    am in jdeveloper 11.1.1.6.0

    1) In your Application module, create a public method in service class.
    2) In that method you do your executeEmptyRowSet() on the view objects you want to.
    3) Expose the method (AM > Services > Client interface).
    4) Drag the method from your DataControl onto you taskflow.
    5) Right click that method > Mark Activity > Default

  • JavaScript Async Method call on the OnChange event of a lookup

    Hello,
    I try to fill dynamically a lookup-multi field by selecting a value in a dropdownlist based on a lookup field.
    I recreated the onchange event of my dropdowlist by using this code :
    lookupElement.onchange = function () { OnFormationChanged() };
    When a user select an element in the dropdownlist, "OnFormationChanged" event run an Async method who retrieve elements joined with the selected element in the dropdownlist lookup.
    This part works fine, it automatically refresh the multi lookup field but when i save my custom page I got the error :
    Value does
    not fall within expected range
    When I do alert in the OnFormationChanged, it retrieve me for example '0' in the onChange event and '3' in the Asynch event as you can see in this screenshot :
    I deduced that the save event method take a wrong result.
    For example :
    A : If I select in the lookup dropdownlist an element with no attached result in the multi lookup, I will have '0' in the "OnFormationChanged" method and '0' in the "OnQuerySucceeded" method and the multilookup will be empty.
    B : If NOW I select in the lookup dropdownlist an element with results in the multi lookup, I will have '0' in the "OnFormationChanged" method and '3' in the OnQuerySucceeded" method and the multilookup will be filled.
    But when I save the custom page I will have the error : Value does not fall within expected range as if async result was not recognized by the save button. 
    Something seems not to be set correctly.Could you give me a way to resolve this issue ?
    DkPoo.

    To close this post, I finally redefinied the save event and it works nicelly now !

  • Automatic popup for reason of rej after an async method

    Hello,
    How to get a reason of rejection popup after an asynchronous method?
    Currently I am using the standard singlerelease method of object type BUS2012 for the release of purchase order. Now once this order gets rejected the user wants an <b>automatic popup for entering the reason for rejection</b> and NOT as another workitem in his inbox for execution.
    Please let me know how can I provide this functionality in the current scenario. <b>Also since the Previous method(singlerelease) is asynchronous “Advance with Dialog” does not work.</b>
    Thanks and Regards,
    Anuj

    It does not work for asynchronous methods but works for synchronous methods. As per SAP the advance with immediate dialog should work for asynchronous methods as well.
    Below is an excerpt from SAP help.
    At runtime, after completion of a step, (= work item has status completed), the workflow system checks the following properties of the subsequent work item:
    •     Is it a dialog work item?
    •     Does the corresponding task refer to a synchronous method?
    •     Is the indicator Advance with dialog set?
    •     Is the actual agent also a recipient of this work item?
    •     Has the work item reached all of its requested starts?
    If the answer to all these questions is yes, the workflow system automatically starts execution of the work item.
    May be you should write a message to SAP. In the meanwhile you can create a synchronous method for the business object.
    -Kiran

  • How to create dynamically a method of a class??

    I would like to create dynamically a method of a class. Is this possible?
    By means of a report I would like to choose a class, to which the defined method should be added and after that I would like to define the name of the method and its parameters. The result should be, that the method is added to the selected class.
    How to do this?
    Regards
    Christian

    Christian,
    looks like an interesting development project. Though I share the doubts Rich has.
    Anyway, what you could possibly do is, start a runtime analysis for SE24, open an existing class, create a new method including desired interface parameters.
    Then analyze it and see what functions/methods are used.
    But It might be more complex than expected.
    Regards,
    Clemens

  • Creating  a static method returning Logger Object inside class

    Hello,
    Instead of creating Logger Instance in every class , can i do like this way by creating a static method in some class returning a Logger object , and using that method for getting instance of Logger in another class through that method
    Regards
    Mayur Mitkari

    On a related note, if you want to make it simpler, never do this:
    if (a == true)Instead, just do if (a)It's pointless and cluttersome to use == or != with true or false.
    // wrong
    if (a == true)
    if (a != false)
    // right
    if (a)
    // wrong
    if (a == false)
    if (a != true)
    // right
    if (!a)Also, note that
    if (x) {
      return true;
    else {
      return false;
    }can be simplified to return x;If you do that and change your variable to something a bit more meaningful, like trueCount or numTrue or something, your code would be
    int trueCount = 0;
    if (a) trueCount++;
    if (b) trueCount++;
    if (c) trueCount++;
    return trueCount >= 2;which is about as simple and clear as it can get, IMHO. Using less code doesn't necessarily make the code simpler or clearer. The idea is that someone reading the code can easily understand what it does.
    And note that the above can be easily generalized to "Are there at least M true values in this array/list of N booleans?" and still be concise and clear.

  • Error in Creating Custom Business Methods using ADF Business Comp. Tutorial

    I've been working with Jdev 10g Preview for a while. Now that we have Jdev 10g, I have to unlearn some of the Preview methods and learn the "real" way of doing things. To that end, I went out to the "Creating Custom Business Methods using ADF Business Components" tutorial. Unfortunately, I've found what I think is a mistake in the example code.
    Specifially, ADF treats the default iterator on View Objects differently than previous BC4J versions. In the older versions, the iterator was positioned before the first row when you first executed a query. In that case, the hasNext() method was used to see if you had any rows at all. In ADF, however, the default iterator is positioned at the first row. So, if your query only returns one row, then the hasNext() method returns false!
    Here's the code posted in the tutorial:
    public Number getDeptSalaryTotal(String dept_id)
    // get a department view object
    DepartmentsViewImpl dept = getDepartmentsView1();
    dept.setWhereClause("DEPARTMENT_ID = " + dept_id);
    dept.executeQuery();
    dept.first();
    EmployeesViewImpl emps = getEmployeesView3();
    Number salaryTotal = new Number(0);
    while (emps.hasNext() )
    Row empsRow = emps.next();
    salaryTotal =
    salaryTotal.add((Number)(empsRow.getAttribute("Salary")));
    return salaryTotal;
    As you can see, this is coded using the pre-10g semantics. It checks hasNext() at the top of the while loop. If there is only one Employee in the Department, hasNext() will return false since the emps View Object will already be positioned at the first and only row. There won't be a next row. So, the salaryTotal will be zero instead of the correct value. Alternatively, if there is more than one row, then hasNext() will be true, but the routine will skip the first row and start totalling salaries from the second row on.
    The routine should be recoded as follows:
    public Number getDeptSalaryTotal(String dept_id)
    // get a department view object
    DepartmentsViewImpl dept = getDepartmentsView1();
    dept.setWhereClause("DEPARTMENT_ID = " + dept_id);
    dept.executeQuery();
    dept.first();
    EmployeesViewImpl emps = getEmployeesView3();
    Number salaryTotal = new Number(0);
    Row empsRow = emps.first(); // Get the first row
    while (empsRow != null ) // while we have a row
    salaryTotal =
    salaryTotal.add((Number)(empsRow.getAttribute("Salary"))); // add in the salary
    empsRow = emps.next(); // get the next row
    return salaryTotal;
    I haven't actually executed this code, so there may be a typo or two in there. However, the basic idea is sound -- I think!
    Please update the tutorial so we don't mislead people right at the start! :-)

    Gary:
    I have two questions for you:
    1) Could you post the preferred code here?
    2) Why is it the preferred method? I would think that creating and destroying another object (the temporary iterator) would be a bad thing.

Maybe you are looking for