Skip to main content
Answer

How to await the completion of a PXLongOperation?

  • September 6, 2024
  • 6 replies
  • 588 views

MichaelShirk
Captain II
Forum|alt.badge.img+5

I have code that I want to run after a long running operation completes, if a method in the long running operation returns ‘true’, to show a simple error message popup.

PXLongOperation.WaitCompletion(key);

PXLongOperation.WaitCompletion(key); seems to be what I need, but I can’t figure out what to use for the key. When I use ‘this’ as shown in the screenshow, it doesn’t find the long running operation and proceeds to skip over the error message code since the variable value will be null.

What am I doing wrong here?

Best answer by Django

It will be the graph that you’re waiting for. If that graph is an extension of another graph because you’ve added functionality then you’ll want to use:

Base.UID

6 replies

Forum|alt.badge.img+7
  • Captain II
  • September 6, 2024

It will be:

PXLongOperation.WaitCompletion(this.UID);

 

 


MichaelShirk
Captain II
Forum|alt.badge.img+5
  • Author
  • Captain II
  • September 6, 2024

@Django  That’s what I thought too, but apparently not, or I’m also doing something else wrong.
 

 


Forum|alt.badge.img+7
  • Captain II
  • Answer
  • September 6, 2024

It will be the graph that you’re waiting for. If that graph is an extension of another graph because you’ve added functionality then you’ll want to use:

Base.UID


MichaelShirk
Captain II
Forum|alt.badge.img+5
  • Author
  • Captain II
  • September 6, 2024

@Django  Is that the case even though I used the “this” keyword to pass the graph extension as the key when I started the long operation?

 


Forum|alt.badge.img+7
  • Captain II
  • September 6, 2024

Sorry - should probably be:

this.Base.UID

I’m basing that off of the error message which is saying that a graph extension doesn’t have a method called UID. But this.Base will have that (unless Base is also a graph extension in which case this.Base.Base.UID (I think))

When I searched the source code for PXLongOperation.WaitCompletion I see references to code that uses a key variable. But in those cases, the code has created a GUID for value of the key variable and then passed that variable to a PXLongOperation.StartOperation(key… call followed by PXLongOperation.WaitCompletion(key);

 

 


MichaelShirk
Captain II
Forum|alt.badge.img+5
  • Author
  • Captain II
  • September 6, 2024

It will be the graph that you’re waiting for. If that graph is an extension of another graph because you’ve added functionality then you’ll want to use:

Base.UID

This works.
using: this.Base.UID is apparently unnecessary.

Thanks for your help!