private void TextView_Closed(object sender, EventArgs e) { if (currentParserKey != null) { ParserStore.Instance.Release(this, currentParserKey); currentParserKey = null; } if (currentTagListKey != null) { TagListStore.Instance.Release(this, currentTagListKey); currentTagListKey = null; } currentTagList = null; }
public IStreamParser GetParser(ColumnDefinition column) { var userId = column.SourceAccounts.First(); var key = new ParserKey(userId, StreamingType.User); IStreamParser parser; if (!LoadedParsers.TryGetValue(key, out parser)) { parser = StreamParser.Create(new StreamingConnection(ContextList.Contexts.First(c => c.UserId == userId) .Twitter.Streaming.GetUserStream())); LoadedParsers.Add(key, parser); } return(parser); }
protected QmlAsyncClassifier( string classificationType, ITextView textView, ITextBuffer buffer) { TextView = textView; textView.Closed += TextView_Closed; Buffer = buffer; buffer.Changed += Buffer_Changed; dispatcher = Dispatcher.CurrentDispatcher; timer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, dispatcher) { Interval = TimeSpan.FromMilliseconds(250) }; timer.Tick += Timer_Tick; currentParserKey = null; currentTagListKey = null; currentTagList = null; this.classificationType = classificationType; AsyncParse(buffer.CurrentSnapshot); }
protected void AddParser(IStreamParser parser, ParserKey key) { parser.FriendsReceived += Parser_FriendsReceived; LoadedParsers.Add(key, parser); }
private async void AsyncParse(ITextSnapshot snapshot) { lock (criticalSection) { if (flag) { return; } flag = true; } var newParserKey = new ParserKey(snapshot); var newTagListKey = new TagListKey(classificationType, snapshot); if (newParserKey == currentParserKey || newTagListKey == currentTagListKey) { return; } ParserKey oldParserKey = null; TagListKey oldTagListKey = null; await Task.Run(() => { var parser = ParserStore.Instance.Get(this, newParserKey); var tagList = TagListStore.Instance.Get(this, newTagListKey); var refresh = ClassificationRefresh.FullText; try { var accessType = tagList.RequestWriteAccess(this); refresh = ProcessText(snapshot, parser, tagList, accessType == SharedTagList.AccessType.ReadWrite); } finally { tagList.WriteComplete(this); } oldParserKey = currentParserKey; currentParserKey = newParserKey; oldTagListKey = currentTagListKey; currentTagListKey = newTagListKey; currentTagList = tagList; RefreshClassification(snapshot, refresh, tagList); var currentVersion = Buffer.CurrentSnapshot.Version; if (snapshot.Version.VersionNumber == currentVersion.VersionNumber) { timer.Stop(); } else { timer.Start(); } }); lock (criticalSection) { flag = false; } await Task.Run(() => { if (oldParserKey != null) { ParserStore.Instance.Release(this, oldParserKey); } if (oldTagListKey != null) { TagListStore.Instance.Release(this, oldTagListKey); } }); }