Skip to content

Commit 903d2be

Browse files
committed
Run update notification banner on UI thread
This fixes issue #69.
1 parent 9fd5dc7 commit 903d2be

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/VsChromium/Features/AutoUpdate/IUpdateNotificationListener.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ namespace VsChromium.Features.AutoUpdate {
44
/// available" event.
55
/// </summary>
66
public interface IUpdateNotificationListener {
7+
/// <summary>
8+
/// Method invoked when there is a new update available. The method is called
9+
/// on a background thread.
10+
/// </summary>
711
void NotifyUpdate(UpdateInfo updateInfo);
812
}
913
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
using System.ComponentModel.Composition;
22
using VsChromium.Features.ToolWindows;
3+
using VsChromium.Threads;
34

45
namespace VsChromium.Features.AutoUpdate {
56
[Export(typeof(IUpdateNotificationListener))]
67
public class UpdateNotificationListener : IUpdateNotificationListener {
78
private readonly IToolWindowAccessor _toolWindowAccessor;
9+
private readonly ISynchronizationContextProvider _synchronizationContextProvider;
810

911
[ImportingConstructor]
10-
public UpdateNotificationListener(IToolWindowAccessor toolWindowAccessor) {
12+
public UpdateNotificationListener(IToolWindowAccessor toolWindowAccessor, ISynchronizationContextProvider synchronizationContextProvider) {
1113
_toolWindowAccessor = toolWindowAccessor;
14+
_synchronizationContextProvider = synchronizationContextProvider;
1215
}
1316

1417
public void NotifyUpdate(UpdateInfo updateInfo) {
15-
_toolWindowAccessor.CodeSearch.NotifyPackageUpdate(updateInfo);
18+
// We have to run this on the UI thread since we are accessing UI components
19+
_synchronizationContextProvider.DispatchThreadContext.Post(() => {
20+
_toolWindowAccessor.CodeSearch.NotifyPackageUpdate(updateInfo);
21+
});
1622
}
1723
}
1824
}

0 commit comments

Comments
 (0)