A project that I am working on requires me to get the history of a folder containing about 300 entries.
As the title says, when I call the MoveNext() method the first time, it will take about 7 seconds to finish. Is this normal behavior, or should I look at implementing a custom IEnumerator interface to speed things up?
Here's a snippet of code showing what I am talking about...
System.Collections.IEnumerable histEnumerable = vcs.QueryHistory(
item.SourceServerPath,
VersionSpec.Latest,
开发者_如何学Go 0,
RecursionType.Full,
"",
null,
null,
Int32.MaxValue,
true,
false);
System.Collections.IEnumerator histEnumerator = histEnumerable.GetEnumerator();
histEnumerator.MoveNext(); //This method will take about 7 seconds to complete.
Any help on this would be greatly appreciated, thanks.
It sounds like the implementation of QueryHistory is doing some upfront work that makes getting that first item expensive. Your best option is probably to put this in a background thread. I would take a look at the Reactive Extensions. You should be able to pretty easily convert this to a push model and process the data as it comes in without blocking.
You would do something like this:
histEnumerable.ToObservable(Scheduler.TaskPool).Subscribe(a => DoSomething(a));
精彩评论