I would like to try using AsyncCTP with TFS. There is currently a long method that calls RunQuery on a Query TFS instance.
The query provides the APM BeginQuery () and EndQuery () methods. As far as I understand, the recommended approach for transferring them using AsyncCTP looks something like this: (example from the docs)
Task<int>.Factory.FromAsync(stream.BeginRead, stream.EndRead, buffer, offset, count, null);
Also, wrap it in an extension method, as in the docs, so my actual method is as follows:
public static Task<WorkItemCollection> RunQueryAsync(this Query query) { if (query== null) throw new ArgumentNullException("Query"); return Task<WorkItemCollection>.Factory.FromAsync(query.BeginQuery, query.EndQuery, null); }
... but this does not compile. Getting an intellisense "wrong argument" error, which, frankly, I canβt understand, because the types and format look right. One possible problem may be that APM Query methods expect ICanceleableAsyncResult, while Task factory expects IAsyncResult, but looking at the TFS API, ICanceleableAsyncResult is a specialization of IAsyncResult.
Not sure if I am doing this wrong or simply impossible. I would like to be able to do this in the AsyncCTP way, but you may have to go back to the APM pattern - ugh!
source share