@@ -37,8 +37,6 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
37
37
private Process _process ;
38
38
private IntPtr _appWin ;
39
39
40
- private readonly DispatcherTimer _resizeTimer = new DispatcherTimer ( ) ;
41
-
42
40
private bool _isConnected ;
43
41
public bool IsConnected
44
42
{
@@ -78,9 +76,6 @@ public TigerVNCControl(TigerVNCSessionInfo info)
78
76
79
77
_sessionInfo = info ;
80
78
81
- _resizeTimer . Tick += ResizeTimer_Tick ;
82
- _resizeTimer . Interval = new TimeSpan ( 0 , 0 , 0 , 0 , 500 ) ;
83
-
84
79
Dispatcher . ShutdownStarted += Dispatcher_ShutdownStarted ;
85
80
}
86
81
@@ -145,18 +140,6 @@ private async Task Connect()
145
140
146
141
while ( ( DateTime . Now - startTime ) . TotalSeconds < 10 )
147
142
{
148
- // Fix for netcore3.1 https://stackoverflow.com/questions/60342879/process-mainwindowhandle-is-non-zero-in-net-framework-but-zero-in-net-core-unl
149
- /*
150
- try
151
- {
152
- _process = Process.GetProcessById(_process.Id);
153
- }
154
- catch
155
- {
156
- break; // Process has exited
157
- }
158
- */
159
-
160
143
_process . Refresh ( ) ;
161
144
162
145
if ( _process . HasExited )
@@ -167,15 +150,15 @@ private async Task Connect()
167
150
if ( IntPtr . Zero != _appWin )
168
151
break ;
169
152
170
- await Task . Delay ( 50 ) ;
153
+ await Task . Delay ( 100 ) ;
171
154
}
172
155
}
173
156
174
157
if ( _appWin != IntPtr . Zero )
175
158
{
176
159
while ( ! _process . HasExited && _process . MainWindowTitle . IndexOf ( " - TigerVNC" , StringComparison . Ordinal ) == - 1 )
177
160
{
178
- await Task . Delay ( 50 ) ;
161
+ await Task . Delay ( 100 ) ;
179
162
180
163
_process . Refresh ( ) ;
181
164
}
@@ -197,7 +180,9 @@ private async Task Connect()
197
180
198
181
IsConnected = true ;
199
182
200
- // Resize embedded application & refresh
183
+ // Resize embedded application & refresh
184
+ // Requires a short delay because it's not applied immediately
185
+ await Task . Delay ( 250 ) ;
201
186
ResizeEmbeddedWindow ( ) ;
202
187
}
203
188
}
@@ -212,10 +197,10 @@ private async Task Connect()
212
197
if ( ! _closing )
213
198
{
214
199
var settings = AppearanceManager . MetroDialog ;
215
- settings . AffirmativeButtonText = NETworkManager . Localization . Resources . Strings . OK ;
200
+ settings . AffirmativeButtonText = Localization . Resources . Strings . OK ;
216
201
ConfigurationManager . Current . FixAirspace = true ;
217
202
218
- await _dialogCoordinator . ShowMessageAsync ( this , NETworkManager . Localization . Resources . Strings . Error ,
203
+ await _dialogCoordinator . ShowMessageAsync ( this , Localization . Resources . Strings . Error ,
219
204
ex . Message , MessageDialogStyle . Affirmative , settings ) ;
220
205
221
206
ConfigurationManager . Current . FixAirspace = false ;
@@ -239,7 +224,7 @@ private void ResizeEmbeddedWindow()
239
224
240
225
public void Disconnect ( )
241
226
{
242
- if ( _process != null && ! _process . HasExited )
227
+ if ( IsConnected )
243
228
_process . Kill ( ) ;
244
229
}
245
230
@@ -262,16 +247,9 @@ public void CloseTab()
262
247
#region Events
263
248
private void TigerVNCGrid_SizeChanged ( object sender , SizeChangedEventArgs e )
264
249
{
265
- if ( _process != null )
250
+ if ( IsConnected )
266
251
ResizeEmbeddedWindow ( ) ;
267
252
}
268
-
269
- private void ResizeTimer_Tick ( object sender , EventArgs e )
270
- {
271
- _resizeTimer . Stop ( ) ;
272
-
273
- ResizeEmbeddedWindow ( ) ;
274
- }
275
253
#endregion
276
254
}
277
255
}
0 commit comments