PDA

View Full Version : [CLOSED] Stop a Task in TaskManager from Code Behind



Peter.Treier
May 15, 2018, 11:46 AM
Hi everybody
first Time that I use the TaskManager, therefore this Question.

Here's my Markup


<ext:TaskManager ID="mainTaskManager" runat="server">
<Tasks>
<ext:Task
TaskID="taskRefresh"
Interval="60000">
<DirectEvents>
<Update OnEvent="LoadData">
<EventMask
ShowMask="true"
Target="CustomTarget"
CustomTarget="={#{mainChart}}" />
</Update>
</DirectEvents>
</ext:Task>
</Tasks>
</ext:TaskManager>

I'd like to stop this 'taskRefresh' Task from Code Behind...

I tried this code - didn't work


internal void SetRefreshInterval(TaskManager manager)
{
var interval = GetRefreshIntervallFromSetting(WidgetClass, WidgetInstance);
var task = manager.Tasks.FirstOrDefault(t => t.TaskID == "taskRefresh");

if (task != null && interval == 0)
{
manager.StopTask("taskRefresh");
return;
}
if (task != null)
{
manager.StartTask("taskRefresh");
task.Interval = interval;
}
}

What's wrong here ?

Thanks for your Help - Peter

Peter.Treier
May 16, 2018, 7:43 AM
Any Idea ?

fabricio.murta
May 16, 2018, 4:10 PM
Hello Peter!

Sorry for the delay, we don't have an answer yet, please hold on a while more as we investigate on a possible solution for this. As you didn't provide a runnable test case reproducing your scenario, we may provide an answer based in one example within examples explorer, which may not reflect your scenario.

If you're concerned with this, please provide a test case resembling your actual scenario meanwhile.

fabricio.murta
May 16, 2018, 7:27 PM
Actually, Peter... Our example pretty much does what you need so, either you didn't look it up or it does not really do what you need...

If you didn't already, please take a look in our example on tasks, it marks the task to be stopped in different ways from code behind:

- TaskManager > Basic > Poll Server (http://examples4.ext.net/#/TaskManager/Basic/Poll_Server/)

Or let us know how it does not fill your needs. Notice there must be an "intermission" between the server and client where the server sends the "finish request" so client side can handle the task feedback UI stopping.

Hope this helps!

Peter.Treier
May 17, 2018, 8:23 AM
Good Morning Fabricio

After a bit playing arround I found a way to stop the task!
In my case the task is marked as 'autorun'. If I set the 'autorun' to false at the stop, all works as expected!

For me OK like that...
We can close this Thread.

Peter

fabricio.murta
May 17, 2018, 3:23 PM
Hello Peter!

I'm sorry the provided sample didn't really help, yet glad you could find an answer and shared the outcome with us!

I see most discussions in the forums involve using task manager without autorun so and maybe when you need to handle it manually, customize some of its behavior, and so on, that -may- be best to disable its autorun and handle it manually.

But there's this old discussion that may be helpful in the future, the comment that shows up on click in specific, but it may be old news (as it was for ExtJS 3, Ext.NET 1): TaskManager Autorun Comment #6 (https://forums.ext.net/showthread.php?4237-CLOSED-TaskManager-AutoRun&p=103445&viewfull=1#post103445).

Leaving a reference to this related discussion here just in case.

Thanks again for your feedback!