Using IProgressMon for my custom IOperation

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
zarkogajic
User
Posts: 736
Joined: Thu Sep 05, 2019 12:35 pm

Using IProgressMon for my custom IOperation

Post by zarkogajic » Thu Nov 19, 2020 1:32 pm

Hi Support,

How would I go about displaying the standard progress monitor for my IOperation being done in the background (AsyncDo...)?

I've tried with

Code: Select all

//pseudo code
MyIOperation.Do
{
	IProgressMon iProgress = Inst.DefaultProgressMon;
	iProgress.Duration = 100;

	ALSO TRIED:

	IProgressMon iProgress = InstAUX.CreateStdRangeProgressMon(Inst.DefaultProgressMon, 100)

	iProgress.Start
	
	while Pos < 100
	{
		//do something...
		
		iProgress.Pos += 1
	}
	iProgress. Stop
}
No errors, but the progress dialog does not come up...


-žarko

User avatar
Sasha - Tracker Dev Team
User
Posts: 5109
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Using IProgressMon for my custom IOperation

Post by Sasha - Tracker Dev Team » Thu Nov 19, 2020 2:33 pm

Hello zarkogajic,

For starters, as you have mentioned, the progress should be used, when the operation is called via the Async method.
The procedure should be as followed:
1) Obtain the progress monitor via the IPXV_Inst::ProgressMon
2) Set you title, style and text. Also, put a duration for your progress.
3) Call a Start method
4) For each needed iteration, you should change the position of the progress and also text if needed
5) Call a Stop method

Note, that if the operation is very fast, then the progress won't show itself as it has a small timer to appear.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 736
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using IProgressMon for my custom IOperation

Post by zarkogajic » Thu Nov 19, 2020 3:38 pm

Hi Alex,

Thanks.
Note, that if the operation is very fast, then the progress won't show itself as it has a small timer to appear
That was it - too fast :)

Can I alter the timer so it starts earlier?

Btw, say I execute multiple IOperations using AsyncDo and each uses a progress dialog: Inst.ProgressMon. Inst.ProgressMon is singleton, right? Seems I would need to go with CreateStdRangeProgressMon (?) as each operation being executed at the same time will have different values (duration, pos text, ...)


-žarko

zarkogajic
User
Posts: 736
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using IProgressMon for my custom IOperation

Post by zarkogajic » Thu Nov 19, 2020 3:59 pm

Hi Alex,

So, yes Inst.ProgressMon is a singleton - therefore cannot use it when having multiple IOperations running at the same time (all called via AsyncDo).

I've tried using InstAUX.CreateStdRangeProgressMon[Ex]() but progress dialog does *not* come up (I have ensured code execution is slow).

Any more coding required for CreateStdRangeProgressMon to work as expected?

-žarko

User avatar
Sasha - Tracker Dev Team
User
Posts: 5109
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Using IProgressMon for my custom IOperation

Post by Sasha - Tracker Dev Team » Fri Nov 20, 2020 7:56 am

Hello zarkogajic,

How do you imagine 5 separate progress dialogs running at the same time?
Probably you can use one parent progress dialog and let the operation use it's parts as a subprogress.
Basically what this means is telling the operation, that it's duration is 10 from 100. For that we have the IAUX_Inst::CreateStdRangeProgressMon method. But, that will work if you have a operation, that is being launched in the separate thread and it calls few other operations in the same thread.
In your case, this will be harder, as you are launching all of the operations from the different threads in parallel. How I see that this can be done is you will need one wrapper operation of some sort that will create and show the progress and will wait for all other operations to finish. Meanwhile, you will have an atomic progress position counter that will be increased from each operation while it's doing it's work. Basically you should pass an object of that progress to each of the operation, and also pass a delta that will tell how much duration it can fill from the 100%. This will allow to increase the progress position from each operation simultaneously, as the counter would be atomic (if not - just use the critical section of some sort).

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 736
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using IProgressMon for my custom IOperation

Post by zarkogajic » Fri Nov 20, 2020 10:11 am

Hi Alex,
How do you imagine 5 separate progress dialogs running at the same time?
An example would be how Windows does copy operation for multiple copy operations. Older Windows versions would display separate "standalone" progress dialogs for each copy operation. Newer Windows would have one dialog with multiple progress bars.
Probably you can use one parent progress dialog and let the operation use it's parts as a subprogress... For that we have the IAUX_Inst::CreateStdRangeProgressMon method.... But, that will work if you have a operation, that is being launched in the separate thread and it calls few other operations in the same thread.
Thanks for explanation , but I still do not quite get the idea of CreateStdRangeProgressMon :( for *one* "multi step" operation (never mind now I'm running multiple operations in parallel)

If I would have as above, one "parent" operation with multiple "child" operations, why not simply use Inst.DefaultProgressMon ? Say the "parent" operation does 3 "separate" operations (in the same thread). Op1 has 3 steps, Op2 has 10 steps and Op3 has 7 steps. In total that is 20 steps. I could set Duration to 20 and simply set the Pos one step at the time: first 3 steps while Op1, then +10 steps while Op2 and finally +7 steps for Op3.

I do not see why, in the above, I would need to use CreateStdRangeProgressMon?

p.s.
Anyhow, what I'm doing right now is: using DefaultProgressMon. In each step of every operation (being run in different threads) I'm setting both the Duration and the Pos (and Text, Title) related to the "current" operation.

This works.

Yes, it has a weird looking effect since you constantly see progress values (both pos and duration and therefore %) being changed - but it is usable and does provide some feedback.

-žarko
Last edited by zarkogajic on Fri Nov 20, 2020 10:19 am, edited 1 time in total.

User avatar
Sasha - Tracker Dev Team
User
Posts: 5109
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Using IProgressMon for my custom IOperation

Post by Sasha - Tracker Dev Team » Fri Nov 20, 2020 10:18 am

Hello zarkogajic,

You wont need the CreateStdRangeProgressMon as I mentioned earlier - it won't work for your case correctly.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 736
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using IProgressMon for my custom IOperation

Post by zarkogajic » Fri Nov 20, 2020 10:21 am

Hi Alex,

Please *ignore* my case (multiple parallel operations).

I do not see why/when I would need to use CreateStdRangeProgressMon. When, how I explained it, all can be done via DefaultProgressMon.

-žarko

User avatar
Sasha - Tracker Dev Team
User
Posts: 5109
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Using IProgressMon for my custom IOperation

Post by Sasha - Tracker Dev Team » Fri Nov 20, 2020 10:35 am

Hello zarkogajic,

Imaging that you have an operation that calls 3 more operations inside. Each operation is a black box that does something. All it has is a parameter where you can pass a progress. The question is how to tell those operation what duration should they use inside of it. For example, one of them works with 1243 pages, other goes through the bookmarks, and another one gets named destinations. All of them have different durations and types of items. Thus when we have a parent progress we should create a child progress and set the duration of it in terms of the parent progresses duration. Meaning, you can set the duration of the parent progress to 100 and 20, 10 and 70 will go to the sub progresses. All of those operation will get the subprogress interface from the passed parameter and will use it as a normal progress inside (for example set the duration for 1243 pages). All of this will result, that the 1243 pages passing will be only 20 points of duration on the main progress.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 736
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using IProgressMon for my custom IOperation

Post by zarkogajic » Fri Nov 20, 2020 11:03 am

HI Alex,

Thanks. But I must be missing something. I do understand what you are saying, but:

I still think this all can be done via DefaultProgressMon - all those 3 operations have access to it and can set the step.
you can set the duration of the parent progress to 100 and 20, 10 and 70..
Yes, I can set the duration of DefaultProgressMon to 100. First 20 moves will be done by "child" operation 1, next 10 by Child2 and finally last 70 by Child3. They are in the same thread so they are executed sequentially.

If Child1 goes over 1243 pages it can still move only 20 steps in the (main) progress bar (so not one step for each page).

I guess the easiest to understand and clear out misunderstanding on my side (obviously) would be if there's some sample code for the CreateStdRangeProgressMon usage?

-žarko

User avatar
Sasha - Tracker Dev Team
User
Posts: 5109
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Using IProgressMon for my custom IOperation

Post by Sasha - Tracker Dev Team » Fri Nov 20, 2020 11:06 am

Hello zarkogajic,

The thing is you don't have access to the operation's black box, and you can't tweak it's inner work. You only can pass the progress it can use. That's the main point of the subprogress. The operation don't know about you parent progress or anything else, it just does it's work,.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 736
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using IProgressMon for my custom IOperation

Post by zarkogajic » Sat Nov 21, 2020 8:52 am

Hi Alex,

Thanks.

A simple example, even if pseudo code, if possible?


Post Reply