Domanda

I recently posted a question on Using Delegates to simulate connected objects where I received a great answer on using the TPL DataFlow library to very easily and cleanly develop a solution to my application.

The problem is that I am stuck on .NET 3.5 or under for C#. I thought I might have been able to upgrade to .NET 4.5 be I cannot at this stage. As far as I've been able to determine I cannot retarget the Dataflow library to .NET 3.5 so my next solution is to look for a C++ alternative under a similar vein to that of TPL Dataflow - Its not the best scenario but I can compile C++ code to a DLL and import it to our C# application.

To summarize my requirements for a C++ library for this question:

  • I need to be able to connect nodes together in complex networks and pass units of a resource between them. Some of them will produce finite amounts of resource over time. Others will consume it at a specific rate.
È stato utile?

Soluzione

You might consider using mono's version of TPL Dataflow and compiling it yourself for .Net 3.5.

I think the biggest problem you'll encounter when trying to compile that code is that it relies heavily on TPL, which is not normally available for .Net 3.5. But it seems a backported version is available in older versions of Rx, so using that could work.

(Also, parts of the mono's version of TDF was written by me and I didn't receive pretty much any feedback about it, so it's quite certain there are bugs in there.)

Altri suggerimenti

Fortunately someone seems to be creating a C++ equivalent of C# TPL Dataflow: https://github.com/renestein/Rstein.AsyncCpp#Flat-Dataflow

Snippet:

 auto transform1 = DataFlowAsyncFactory::CreateTransformBlock<int, string>([](const int& item)-> Tasks::Task<string>
                                                      {
                                                        auto message = "int: " + to_string(item) + "\n";
                                                        cout << message;
                                                        //await async operation returning standard shared_future.
                                                        co_await GetCompletedSharedFuture();
                                                        co_return to_string(item);
                                                      });
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top