|
Rank: Member Groups: Member
Joined: 5/14/2020 Posts: 19
|
I have a problem with setting cookies. The method WebView.Engine.CookieManager.SetCookie() simply does not return. It only happens the second time this method is called. The whole application does not repond anymore but no error is thrown.
|
|
Rank: Member Groups: Member
Joined: 5/14/2020 Posts: 19
|
I have tried to work around the problem by first checking with the GetCookies method whether the cookie I want to set already exists. Unfortunately the method GetCookies does not return the second time I call it.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Which version do you use?
|
|
Rank: Member Groups: Member
Joined: 5/14/2020 Posts: 19
|
20.1.88
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, Please make sure you DO NOT call SetCookie from your main UI thread. Calling SetCookie from your main UI thread will cause it to hang. For example, if you handle a Button's Click event and you have the following code:
Code: C#
private void Button1_Click(object sender, EventArgs e)
{
webView.Engine.CookieManager.SetCookie(....);
}
Then SetCookie will hang because it is called by Button1_Click event handler, which is called by your main UI thread. To avoid this problem, call the code in a thread pool thread:
Code: C#
private void Button1_Click(object sender, EventArgs e)
{
System.Threading.ThreadPool.QueueUserWorkItem((arg) =>
{
webView.Engine.CookieManager.SetCookie(....);
}, null);
}
Please let us know if this works for you. Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
This is just to let you know that we have posted a new build that no longer requires you to call SetCookie in a background thread. You can download the new build from our download page.
Thanks!
|
|