我正在构建一个将视频发布到用户域的应用程序。我使用了webbrowser控件。它运行良好而没有错误。但是当应用程序有更多要发布的视频时,它有时会卡住。
就像当我点击代码中的提交按钮时效果很好但是当它执行此操作可能是10次时它停止rite有时它会在一些延迟之后继续,并且如果我们手动单击按钮它也会继续。
这是一件奇怪的事情。有什么可能是错的,或者可能是缓存存在一些问题。
如果有替代方法,请告诉我
DocumentComplete事件中的代码
//Select HTML view
if (webBrowserPostVideo.Document.GetElementById("edButtonHTML") != null)
webBrowserPostVideo.Document.GetElementById("edButtonHTML").InvokeMember("click");
//Enter Content
if (webBrowserPostVideo.Document.GetElementById("content") != null)
{
webBrowserPostVideo.Document.GetElementById("content").InvokeMember("click");
webBrowserPostVideo.Document.GetElementById("content").InvokeMember("click");
webBrowserPostVideo.Document.GetElementById("content").InvokeMember("click");
webBrowserPostVideo.Document.GetElementById("content").SetAttribute("InnerText",
youtubeVideos[SelectedVideo].VideoCode
.Replace("<HTML>", "").Replace("</HTML>", "").Replace("<BODY>", "").Replace("</BODY>", ""));
}
//post Month
if (webBrowserPostVideo.Document.GetElementById("mm") != null && youtubeVideos[SelectedVideo].PostingDateTime.Substring(6, 2) != null)
webBrowserPostVideo.Document.GetElementById("mm").SetAttribute("value",
youtubeVideos[SelectedVideo].PostingDateTime.Substring(5, 2));
//Post Date
if (webBrowserPostVideo.Document.GetElementById("jj") != null && youtubeVideos[SelectedVideo].PostingDateTime.Substring(8, 2) != null)
webBrowserPostVideo.Document.GetElementById("jj").SetAttribute("value",
youtubeVideos[SelectedVideo].PostingDateTime.Substring(8, 2));
//Post Year
if (webBrowserPostVideo.Document.GetElementById("aa") != null && youtubeVideos[SelectedVideo].PostingDateTime.Substring(0, 4) != null)
webBrowserPostVideo.Document.GetElementById("aa").SetAttribute("value",
youtubeVideos[SelectedVideo].PostingDateTime.Substring(0, 4));
//Post Hour
if (webBrowserPostVideo.Document.GetElementById("hh") != null && youtubeVideos[SelectedVideo].PostingDateTime.Substring(11, 2) != null)
webBrowserPostVideo.Document.GetElementById("hh").SetAttribute("value",
youtubeVideos[SelectedVideo].PostingDateTime.Substring(11,2));
//Post Minutes
if (webBrowserPostVideo.Document.GetElementById("mn") != null && youtubeVideos[SelectedVideo].PostingDateTime.Substring(14, 2) != null)
webBrowserPostVideo.Document.GetElementById("mn").SetAttribute("value",
youtubeVideos[SelectedVideo].PostingDateTime.Substring(14, 2));
//Enter Video Title
if (webBrowserPostVideo.Document.GetElementById("title") != null)
webBrowserPostVideo.Document.GetElementById("title").SetAttribute("value", youtubeVideos[SelectedVideo].VideoTitle);
if (webBrowserPostVideo.Document.GetElementById("publish") != null)
{
Thread.Sleep(2000);
webBrowserPostVideo.Document.GetElementById("publish").InvokeMember("click");
webBrowserPostVideo.Document.GetElementById("publish").InvokeMember("click");
Thread.Sleep(2000);
SelectedVideo++;
webBrowserPostVideo.Document.GetElementById("publish").InvokeMember("click");
}