How cancel a httpJob

yuhong

Member
Licensed User
Longtime User
:sign0085:

I found CancelDownload in DownloadService module,Can you move it to HttpUtils2 module?


B4X:
Public Sub CancelDownload(url As String)
   If jobs.ContainsKey(url) = False Then
      Log("Ignoring cancel request.")
      Return
   End If
   Dim job As HttpJob = jobs.Get(url)
   Dim jt As JobTag = job.Tag
   If jt.CountingStream.IsInitialized Then
      jt.CountingStream.Close
   Else
      jt.Data.url = ""
   End If
End Sub

I send URL run long time and exit current activity, this httpjob not over,So I want cancel it.
 

yuhong

Member
Licensed User
Longtime User
B4X:
Sub CancelJob(url As String)
   If TaskIdToJob.ContainsKey(url)=False Then
      Log("Ignoring cancel request.")
      Return
   End If
   Dim job As HttpJob=TaskidTojob.Get(url)
   Dim jt As JobTag=job.Tag
   If jt.CountingStream.IsInitialized Then
      jt.CountingStream.Close
   Else
      jt.Data.url=""
   End If
End Sub

I write code for cancel job.
help me , Is it right?
 
Upvote 0

yuhong

Member
Licensed User
Longtime User
I plan to add a Cancel method for HttpJob in the future.

This is too important for me is good news! Because in the long http request execution process, user are likely to return to the previous Activity.

Thank you !!!
 
Upvote 0

yuhong

Member
Licensed User
Longtime User
Because the network is slow, very long time to perform a task, the user will exit the current activity, and then enter this, the question came.

my user say:"System unstable!":sign0085: So ,I hope early realization of "Cancel" function .
 
Upvote 0
Top