Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6197547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:50:25+00:00 2026-05-24T03:50:25+00:00

I created a F# library that returns this datatype FSharpAsync<IEnumerable<Tupel<DateTime,string>>> How do I access

  • 0

I created a F# library that returns this datatype

FSharpAsync<IEnumerable<Tupel<DateTime,string>>>

How do I access the FSharpAsync type so I can enumerate through the tuple from C# and print out the content?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:50:26+00:00Added an answer on May 24, 2026 at 3:50 am

    It is generally not recommended to expose F# types such as FSharpAsync in a public interface that will be used by C# clients (see F# component design guidelines). You can use Async.StartAsTask (on the F# side) to expose the operation as a Task<T> that is easy to use from C#.

    In fact, I would also replace the tuple with a named type (that captures the meaning of the data structure). Tuples can be used in C#, but they are not idiomatic in C#:

    // Assuming you have an operation like this 
    let asyncDoWork () : Async<seq<DateTime * string>> = (...)
    
    // Define a named type that explains what the date-string pair means
    type Item(created:DateTime, name:string) =
      member x.Created = created
      member x.Name = name
    
    // Create a simple wrapper that wraps values into 'Item' type
    let asyncDoWorkItems () = 
      async { let! res = asyncDoWork()
              return seq { for (d, n) in res -> Item(d, n) } }
    

    Now, to expose the operation to C#, the best practice is to use a type with an overloaded static method. The method starts the operation as a task and one overload specifies cancellation token. The C# naming convention for these is to add Async to the end of the name (which doesn’t overlap with F# which adds Async to the front):

    type Work = 
      static member DoWorkAsync() =
        Async.StartAsTask(asyncDoWorkItems())
      static member DoWorkAsync(cancellationToken) =
        Async.StartAsTask(asyncDoWorkItems(), cancellationToken = cancellationToken)
    

    Your C# code can then use Work.DoWorkAsync() and work with the task in the usual C# style. It will even work with the await keyword that will be (probably) added to C# 5.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible for gcc to link against a library that was created with
Im trying to find out a good JavaScript library that can create a nice
I have created a VB.NET 2008 Class Library that has, for the most part,
If you create a class library that uses things from other assemblies, is it
Is there any feasible way of using generics to create a Math library that
Here's what I'd like to do: I want to create a library project that
How do you create a lookup column to a Document Library that uses the
I'm looking for a python library that will help me to create an authentication
I'm trying to create a splash screen that shows assemblies (all referenced library) loading
I'm trying to use a static library created by me in Visual C++ 2005

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.