質問編集履歴
3
コードの編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,7 +26,6 @@
|
|
26
26
|
|
27
27
|
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args)
|
28
28
|
{
|
29
|
-
|
30
29
|
Debug.Print("OnLoadingStateChanged is occured!");
|
31
30
|
if (args.IsLoading)
|
32
31
|
{
|
2
コードの編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,21 +3,13 @@
|
|
3
3
|
似たような質問が[CefSharp documentcompleted](https://stackoverflow.com/questions/41985380/cefsharp-documentcompleted)のサイトにありました。
|
4
4
|
CefSharpはLoadingStateChangedイベントをもっているようです。
|
5
5
|
このイベントを利用してページの読み込みを待つにはどうすればよいのでしょうか?
|
6
|
-
私なりに試した結果がこちらになります。browser.Address ="https://www.google.com/";の後にOnLoadingStateChangedイベントは起こっております。しかしながら問題があります。
|
7
6
|
|
8
|
-
[1つ目の問題点]
|
9
|
-
|
7
|
+
私なりに試した結果がこちらになります。**browser.Address ="https://www.google.com/";**の後にOnLoadingStateChangedイベントは起こっております。
|
10
|
-
[2つ目の問題点]
|
11
|
-
|
8
|
+
しかしながら **browser.Load("http://github.com"); **の前に待つための処理を書きたいのですがどのようにしたらよいのか思い付きません。
|
12
|
-
```
|
13
|
-
public Browser()
|
14
|
-
{
|
15
|
-
InitializeComponent();
|
16
|
-
start();
|
17
|
-
}
|
18
9
|
|
19
10
|
|
11
|
+
```
|
20
|
-
|
12
|
+
public async void start()
|
21
13
|
{
|
22
14
|
var settings = new CefSettings()
|
23
15
|
{
|
@@ -28,21 +20,19 @@
|
|
28
20
|
Content = browser;
|
29
21
|
browser.LoadingStateChanged += OnLoadingStateChanged;
|
30
22
|
browser.Address ="https://www.google.com/";
|
23
|
+
//ここにLoadingStateChangedイベントを利用した待ち処理を行いたい
|
31
24
|
browser.Load( "http://github.com");
|
32
25
|
}
|
33
26
|
|
34
27
|
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args)
|
35
28
|
{
|
29
|
+
|
36
|
-
|
30
|
+
Debug.Print("OnLoadingStateChanged is occured!");
|
37
|
-
|
31
|
+
if (args.IsLoading)
|
38
32
|
{
|
39
|
-
Debug.Print("OnLoadingStateChanged is occured!");
|
40
|
-
if (!args.IsLoading)
|
41
|
-
{
|
42
|
-
break;
|
43
|
-
}
|
44
33
|
}
|
34
|
+
else
|
35
|
+
{
|
36
|
+
}
|
45
37
|
}
|
46
|
-
|
47
|
-
}
|
48
38
|
```
|
1
進んだ箇所を追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,11 +3,46 @@
|
|
3
3
|
似たような質問が[CefSharp documentcompleted](https://stackoverflow.com/questions/41985380/cefsharp-documentcompleted)のサイトにありました。
|
4
4
|
CefSharpはLoadingStateChangedイベントをもっているようです。
|
5
5
|
このイベントを利用してページの読み込みを待つにはどうすればよいのでしょうか?
|
6
|
-
|
6
|
+
私なりに試した結果がこちらになります。browser.Address ="https://www.google.com/";の後にOnLoadingStateChangedイベントは起こっております。しかしながら問題があります。
|
7
7
|
|
8
|
+
[1つ目の問題点]
|
9
|
+
start メソッド内でbrowser.Address ="https://www.google.com/";の後に来るbrowser.Load( "http://github.com");の前に読み込みを待つ処理をしたいが待たずに browser.Load( "http://github.com");が行われる。
|
10
|
+
[2つ目の問題点]
|
11
|
+
OnLoadingStateChangedメソッドが永久にループする。
|
8
12
|
```
|
13
|
+
public Browser()
|
14
|
+
{
|
15
|
+
InitializeComponent();
|
16
|
+
start();
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
public async void start()
|
21
|
+
{
|
22
|
+
var settings = new CefSettings()
|
23
|
+
{
|
24
|
+
Locale = "ja",
|
25
|
+
};
|
9
|
-
Cef.Initialize(
|
26
|
+
Cef.Initialize(settings);
|
27
|
+
CefSharp.Wpf.ChromiumWebBrowser browser = new CefSharp.Wpf.ChromiumWebBrowser();
|
28
|
+
Content = browser;
|
29
|
+
browser.LoadingStateChanged += OnLoadingStateChanged;
|
30
|
+
browser.Address ="https://www.google.com/";
|
10
|
-
browser
|
31
|
+
browser.Load( "http://github.com");
|
32
|
+
}
|
33
|
+
|
34
|
+
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args)
|
35
|
+
{
|
36
|
+
|
37
|
+
while (true)
|
38
|
+
{
|
11
|
-
|
39
|
+
Debug.Print("OnLoadingStateChanged is occured!");
|
12
|
-
|
40
|
+
if (!args.IsLoading)
|
41
|
+
{
|
42
|
+
break;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
13
48
|
```
|