@@ -217,7 +217,7 @@ private void Hyperlink_MouseLeftButtonDown(object sender, MouseButtonEventArgs e
217
217
218
218
#region Build for Hover
219
219
220
- public Dictionary < string , StackTrace > stacks = new Dictionary < string , StackTrace > ( ) ;
220
+ public Dictionary < long , StackTrace > stacks = new Dictionary < long , StackTrace > ( ) ;
221
221
//private async Task find_source(Node nn)
222
222
//{
223
223
// _ = Application.Current.Dispatcher.BeginInvoke(new Action(
@@ -259,6 +259,26 @@ private void Hyperlink_MouseLeftButtonDown(object sender, MouseButtonEventArgs e
259
259
// }
260
260
// }
261
261
//}
262
+ private async Task find_source ( Node nn )
263
+ {
264
+ _ = Application . Current . Dispatcher . BeginInvoke ( new Action (
265
+ delegate
266
+ {
267
+ URLText . Text = nn . NodeId . ToString ( ) ;
268
+ } ) ) ;
269
+ var st = await ss . SendAsync ( new GetNodeStackTracesCommand { NodeId = nn . NodeId } ) ;
270
+ if ( st . Result != null && st . Result . Creation != null )
271
+ {
272
+ stacks . Add ( nn . NodeId , st . Result . Creation ) ;
273
+ }
274
+ if ( nn . Children != null )
275
+ {
276
+ foreach ( var child in nn . Children )
277
+ {
278
+ await find_source ( child ) ;
279
+ }
280
+ }
281
+ }
262
282
263
283
private void init_overlay ( )
264
284
{
@@ -338,13 +358,29 @@ await Application.Current.Dispatcher.BeginInvoke(new Action(
338
358
Build . IsEnabled = false ;
339
359
} ) ) ;
340
360
341
- var doc = await ss . SendAsync ( new GetDocumentCommand { Depth = - 1 } ) ;
361
+ var docTask = ss . SendAsync ( new GetDocumentCommand { Depth = - 1 } ) ;
362
+ var whenAnyTask = await Task . WhenAny ( docTask , Task . Delay ( TimeSpan . FromSeconds ( 10 ) ) ) ;
342
363
343
- if ( doc . Result != null )
364
+ if ( whenAnyTask != docTask )
344
365
{
345
- //stacks = new Dictionary<string, StackTrace>();
346
- //await find_source(doc.Result.Root);
366
+ await Application . Current . Dispatcher . BeginInvoke ( new Action (
367
+ delegate
368
+ {
369
+ MessageBox . Show ( "Please try again later! " +
370
+ "If this error persists, restart the program. " +
371
+ "If that continues, please open new issue to https://github.com/rollrat/custom-crawler." ,
372
+ "Custom Craweler" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
373
+ Build . IsEnabled = true ;
374
+ } ) ) ;
375
+ return ;
376
+ }
347
377
378
+ var doc = await docTask ;
379
+
380
+ if ( doc . Result != null )
381
+ {
382
+ stacks = new Dictionary < long , StackTrace > ( ) ;
383
+ await find_source ( doc . Result . Root ) ;
348
384
}
349
385
else
350
386
{
0 commit comments