質問編集履歴

3

コードの編集

2019/01/11 13:40

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -54,8 +54,6 @@
54
54
 
55
55
  {
56
56
 
57
-
58
-
59
57
  Debug.Print("OnLoadingStateChanged is occured!");
60
58
 
61
59
  if (args.IsLoading)

2

コードの編集

2019/01/11 13:40

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -8,35 +8,19 @@
8
8
 
9
9
  このイベントを利用してページの読み込みを待つにはどうすればよいのでしょうか?
10
10
 
11
- 私なりに試した結果がこちらになります。browser.Address ="https://www.google.com/";の後にOnLoadingStateChangedイベントは起こっております。しかしながら問題があります。
12
11
 
13
12
 
13
+ 私なりに試した結果がこちらになります。**browser.Address ="https://www.google.com/";**の後にOnLoadingStateChangedイベントは起こっております。
14
14
 
15
- [1つ目の問題点]
16
-
17
- start メソッド内でbrowser.Address ="https://www.google.com/";の後に来るbrowser.Load( "http://github.com");の前に読み込みを待つ処理をたいがずに browser.Load( "http://github.com");が行われる
15
+ しかしながら **browser.Load("http://github.com"); **の前に待つための処理を書きたいのですどのようにしらよいのか思い付きません
18
-
19
- [2つ目の問題点]
20
-
21
- OnLoadingStateChangedメソッドが永久にループする。
22
-
23
- ```
24
-
25
- public Browser()
26
-
27
- {
28
-
29
- InitializeComponent();
30
-
31
- start();
32
-
33
- }
34
16
 
35
17
 
36
18
 
37
19
 
38
20
 
21
+ ```
22
+
39
- public async void start()
23
+ public async void start()
40
24
 
41
25
  {
42
26
 
@@ -58,6 +42,8 @@
58
42
 
59
43
  browser.Address ="https://www.google.com/";
60
44
 
45
+ //ここにLoadingStateChangedイベントを利用した待ち処理を行いたい
46
+
61
47
  browser.Load( "http://github.com");
62
48
 
63
49
  }
@@ -68,28 +54,22 @@
68
54
 
69
55
  {
70
56
 
71
-
72
57
 
58
+
59
+ Debug.Print("OnLoadingStateChanged is occured!");
60
+
73
- while (true)
61
+ if (args.IsLoading)
74
62
 
75
63
  {
76
64
 
77
- Debug.Print("OnLoadingStateChanged is occured!");
65
+ }
78
66
 
79
- if (!args.IsLoading)
67
+ else
80
68
 
81
- {
69
+ {
82
-
83
- break;
84
-
85
- }
86
70
 
87
71
  }
88
72
 
89
73
  }
90
74
 
91
-
92
-
93
- }
94
-
95
75
  ```

1

進んだ箇所を追記

2019/01/11 13:39

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -8,18 +8,88 @@
8
8
 
9
9
  このイベントを利用してページの読み込みを待つにはどうすればよいのでしょうか?
10
10
 
11
- 参考になるサイトでも構いせんので回答宜くお願い致します。
11
+ 私なり試した結果がこちらにります。browser.Address ="https://www.google.com/";の後にOnLoadingStateChangedベンは起こっておりす。ながら問題があります。
12
12
 
13
13
 
14
14
 
15
+ [1つ目の問題点]
16
+
17
+ start メソッド内でbrowser.Address ="https://www.google.com/";の後に来るbrowser.Load( "http://github.com");の前に読み込みを待つ処理をしたいが待たずに browser.Load( "http://github.com");が行われる。
18
+
19
+ [2つ目の問題点]
20
+
21
+ OnLoadingStateChangedメソッドが永久にループする。
22
+
15
23
  ```
16
24
 
17
- Cef.Initialize(new CefSettings());
25
+ public Browser()
18
26
 
19
- browser = new ChromiumWebBrowser("http://google.com");
27
+ {
20
28
 
21
- //ここにページ読み込みを待つ処理
29
+ InitializeComponent();
22
30
 
31
+ start();
32
+
33
+ }
34
+
35
+
36
+
37
+
38
+
23
- //ぺージ読み込み完了後の処理
39
+ public async void start()
40
+
41
+ {
42
+
43
+ var settings = new CefSettings()
44
+
45
+ {
46
+
47
+ Locale = "ja",
48
+
49
+ };
50
+
51
+ Cef.Initialize(settings);
52
+
53
+ CefSharp.Wpf.ChromiumWebBrowser browser = new CefSharp.Wpf.ChromiumWebBrowser();
54
+
55
+ Content = browser;
56
+
57
+ browser.LoadingStateChanged += OnLoadingStateChanged;
58
+
59
+ browser.Address ="https://www.google.com/";
60
+
61
+ browser.Load( "http://github.com");
62
+
63
+ }
64
+
65
+
66
+
67
+ private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args)
68
+
69
+ {
70
+
71
+
72
+
73
+ while (true)
74
+
75
+ {
76
+
77
+ Debug.Print("OnLoadingStateChanged is occured!");
78
+
79
+ if (!args.IsLoading)
80
+
81
+ {
82
+
83
+ break;
84
+
85
+ }
86
+
87
+ }
88
+
89
+ }
90
+
91
+
92
+
93
+ }
24
94
 
25
95
  ```