Skip to content

Commit 50db505

Browse files
committed
Make the VBERuntime in the ComMessagePumper use lazy initialization instead of that weird funky homebrewn static/instance construction.
Make DetermineVersion static.
1 parent 9371fdb commit 50db505

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Rubberduck.VBEEditor/ComManagement/ComMessagePumper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ namespace Rubberduck.VBEditor.ComManagement
77
public static class ComMessagePumper
88
{
99
private static SynchronizationContext UiContext { get; set; }
10-
private static IVBERuntime Runtime { get; set; }
10+
private static readonly Lazy<IVBERuntime> Runtime = new Lazy<IVBERuntime>(() => new VBERuntimeAccessor());
1111

1212
public static void Initialize()
1313
{
1414
if (UiContext == null)
1515
{
1616
UiContext = SynchronizationContext.Current;
1717
}
18-
19-
Runtime = new VBERuntimeAccessor();
2018
}
2119

2220
/// <summary>
@@ -37,7 +35,7 @@ public static int PumpMessages()
3735
{
3836
CheckContext();
3937

40-
return Runtime.DoEvents();
38+
return Runtime.Value.DoEvents();
4139
}
4240

4341
private static void CheckContext()

Rubberduck.VBEEditor/ComManagement/VBERuntime/VBERuntimeAccessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public VBERuntimeAccessor()
3535
}
3636
}
3737

38-
private IVBERuntime DetermineVersion()
38+
private static IVBERuntime DetermineVersion()
3939
{
4040
IVBERuntime runtime;
4141
try

0 commit comments

Comments
 (0)