File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55using System ;
66using System . Runtime . InteropServices ;
7+ using System . Threading ;
78
89namespace WinDynamicDesktop . COM
910{
@@ -100,9 +101,23 @@ public static class DesktopWallpaperFactory
100101 [ Guid ( "C2CF3110-460E-4fc1-B9D0-8A1C0C9CC4BD" ) ]
101102 class DesktopWallpaperCoclass { }
102103
104+ private const int REGDB_E_CLASSNOTREG = 0x80040154 ;
105+
103106 public static IDesktopWallpaper Create ( )
104107 {
105- return ( IDesktopWallpaper ) new DesktopWallpaperCoclass ( ) ;
108+ for ( int attempt = 0 ; ; attempt ++ )
109+ {
110+ try
111+ {
112+ return ( IDesktopWallpaper ) new DesktopWallpaperCoclass ( ) ;
113+ }
114+ catch ( COMException e ) when ( e . HResult == REGDB_E_CLASSNOTREG && attempt < 3 )
115+ {
116+ LoggingHandler . LogMessage ( "Accessing DesktopWallpaper COM class failed, retrying ({1}/3)" ,
117+ attempt + 1 ) ;
118+ Thread . Sleep ( 1000 ) ;
119+ }
120+ }
106121 }
107122 }
108123}
You can’t perform that action at this time.
0 commit comments