Hi all,
I have written a plugin for Visual Studio , which among other supports outlining and dropdown bar.
The problem is, that when I have huge files, e.g. 100K lines and I make any change to the file, the file will be reparsed in the backgound and the outlining regions updates. Once this is done, I am doing a forceRepaint of the IVsDropdownBar instance.
For huge files, this causes the Visual Studio instance to hang. Why can't this be done in the background ?
I tried putting this call to a background task, but it doesn't matter since it has to be called via the dispatcher and it anyway hangs the ui.
Here is some code:
void OnParserReady(object source, Parsing.ParserDatabase.ParserReadyEventEventArgs e)
{
//if a which belong to this text view is updated update the combo boxes
if (e.Filepath == Utilities.RegistryReader.GetTextDocument(_textView.TextBuffer).FilePath && e.IsParsed )
{
var dropDownBar = _dropDownBar;
//get new command list if available
_body = Parsing.ParserDatabase.Instance.getParsedDocument(e.Filepath, false );
if (dropDownBar != null)
{
if (mTimer.IsEnabled)
{
mTimer.Stop();
}
updateComboBoxCallback = new Action(test);
//Action callback = () => { dropDownBar.RefreshCombo(0, 0);};
//_dispatcher.BeginInvoke(callback, DispatcherPriority.Loaded);
mTimer.Start();
}
}
}
//timer callback actually executes the comborefresh
void test()
{
//if (mRefreshTask != null && !mRefreshTask.IsCompleted)
//{
// //task is running so cancel it
// mRefreshTokenSrc.Cancel();
// mRefreshTask.Wait();
//}
//mRefreshTokenSrc = new CancellationTokenSource();
//mRefreshTask = System.Threading.Tasks.Task.Factory.StartNew(test2, mRefreshTokenSrc.Token, System.Threading.Tasks.TaskCreationOptions.LongRunning, new ThreadPerTaskScheduler());
if (_dropDownBar != null)
{
_dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
{
_dropDownBar.RefreshCombo(0, 0); // <---------------- Here UI hangs for a long time if the file is large enough.
}));
}
}