question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to convert to task?

See original GitHub issue

Probably a stupid question, but I need to convert a Job to a Task because I’m using Giraffe, which is using Task for its HttpHandlers. How can I convert a job to a task? I can’t find any functions in Job with the right signature (I can only find functions from Task to Job, not the other way).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cmeerencommented, Mar 20, 2020

Thanks! I may not properly understand Job or Hopac; I’m currently experimenting with replacing all internal Async stuff in a framework of mine with Job to see if I get better performance (there’s a lot of lifting non-async user code to Async all over the place which causes a bunch of allocations etc.)

0reactions
cmeerencommented, Mar 20, 2020

Thanks! Since I’m not used to the infixes, I found the below clearer:

let startAsTask (xJ: Job<'x>): Task<'x> =
    let tcs = new TaskCompletionSource<'x>()
    job {
      try
        let! x = xJ
        tcs.SetResult x
      with ex -> tcs.SetException ex
    }
    |> start
    tcs.Task
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot implicitly convert type 'string' to 'System.Threading. ...
First, the method is marked as async , which means the return type is wrapped in a Task , making the method compile....
Read more >
Implicit conversion from T to Task<T> · Issue #15892
I would step back and look at it this way: If the method isn't async and isn't waiting on something else, why is...
Read more >
Feature request: convert Task to Project : r/todoist
In the project, turn each subtask into a task by grabbing the gray handle and dragging it to the left. It will then...
Read more >
Convert task to project, then leave task as a task within ...
I can do this manually by going back to “New Enquiries” and making the greyed-out task back into a task and then moving...
Read more >
Convert an issue to a task in Adobe Workfront
Go to a project and click Issues in the left panel. · Click the issue you want to convert to go to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found