[CLOSED] Stop a Task in TaskManager from Code Behind

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Stop a Task in TaskManager from Code Behind

    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
    Last edited by fabricio.murta; May 17, 2018 at 3:23 PM.
  2. #2
    Any Idea ?
  3. #3
    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.
    Fabrício Murta
    Developer & Support Expert
  4. #4
    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

    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!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    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
  6. #6
    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.

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

    Thanks again for your feedback!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Taskmanager, scheduled task and focus on browserwindow
    By CarWise in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 19, 2013, 4:07 PM
  2. Replies: 1
    Last Post: Nov 05, 2012, 8:40 PM
  3. Stop a task from server-side.
    By WiseJiong in forum 2.x Help
    Replies: 7
    Last Post: Jul 31, 2012, 1:14 PM
  4. [CLOSED] Task Update DirectEvent in TaskManager
    By pil0t in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 21, 2010, 8:30 PM

Tags for this Thread

Posting Permissions