There is a C # application that is a constantly open browser window (System.Windows.Forms.WebBrowser) with an online consultant page. Always hangs in the tray and unfolds when there is a question ... Events are caught by JS ...
Script functionality is the simplest:
private void timer1_Tick(object sender, EventArgs e) { label1.Text = er_counter.ToString(); try { if (er_counter > 10) { er_counter = 0; showWindow(); webBrowser1.Refresh(); return; } if (webBrowser1.Document.GetElementById("timestamp").InnerText.Equals(last_date)) { er_counter++; } else { er_counter = 0; } last_date = webBrowser1.Document.GetElementById("timestamp").InnerText; object[] codeString2 = { "$('#webim_userbar>li>a').text().trim();" }; string agent_name = webBrowser1.Document.InvokeScript("eval", codeString2).ToString(); String title = "[" + last_date + "] [" + agent_name + "] Онлайн-консультант"; this.Text = title.ToString(); notifyIcon1.Text = title.ToString(); object[] codeString = { "webim.isActive;" }; string t = webBrowser1.Document.InvokeScript("eval", codeString).ToString(); if( t.Equals("True")) { showWindow(); } } catch { er_counter++; } }
through JS, you get the current agent name and chat status (show a window, or nothing new). Through JS, the music for the new event is still playing in the browser, but I think the catch is not here.
er_counter error counter, if a window suddenly hangs, or the Internet crashes, the starnitsa will update itself and the agent is online again.
At first, all the norms, memory in the region of 30Mb ... but after 5-6 hours of work, it grows to 300mb, and then it grows and grows ... it happened with 1.5-2GB each.
The problem is obvious in a standard browser, tell me you can solve this problem?
WebBrowser
when you need to deploy it? And yes, it's easier to remove the dump from the 300mb + process and see what takes place there. - Monk