1

We are using Biztalk. And in order to implement a disassembler component we must implement a specific interface (IDisassemblerComponent) that of course does not use Task as return type.

On the other hand I'm using a NuGet package that supports a lot of the logic we need (identifying some very specific formats of files), which has a lot of methods that return Task, hence are expected to be async.

Now, my question is - is there any way to avoid having to do the dreaded async to sync "conversion" in this case?

Ykok
  • 1,313
  • 13
  • 15
  • Please explain what you mean by "conversion" and what aspect of it fills you full of dread. – John Wu Aug 24 '18 at 06:15
  • 1
    It just plain isn't expecting to deal with an async implementation. It calls the methods on the interface, when you return from those methods it expects that the job has been completely done. So yes, if your own implementation is using async code, you're going to have to write some blocking code somewhere in your code. – Damien_The_Unbeliever Aug 24 '18 at 06:19
  • 1
    Actually @Damien_The_Unbeliever it looks like you call `Disassemble()` to kick off the process then call `GetNext()`to retrieve the results as they become available. Not an expert on BizTalk. – John Wu Aug 24 '18 at 06:21
  • 1
    @JohnWu - so, you may be able to benefit slightly from async from the `Disassemble` but you'd still need to write some form of blocking rendezvous in the `GetNext` to wait for/pick up each result. – Damien_The_Unbeliever Aug 24 '18 at 06:26
  • Thanks for the comments. If anyone drops by and want a good blocking code (that doesn't deadlock) I recommend looking at this answer: https://stackoverflow.com/questions/40324300/calling-async-methods-from-non-async-code – Ykok Aug 29 '18 at 08:44

1 Answers1

0

Use the Flat File Wizard to generate schema's specific for each format or either make one schema for all formats (if they are pretty similar). On the last option you could promote a property that will act as the message type so you could use it to route the message based on that property.

r3verse
  • 1,000
  • 8
  • 19