C# WebBrowser控件卡住了
我正在构建一个将视频发布到用户域的应用程序。我使用了webbrowser控件。它运行得很好,没有错误。但当应用程序有更多视频要发布时,它有时会卡住 就像我在代码中单击submit按钮一样,它工作得很好,但当它这样做10次时,它可能会停止,有时会在一些延迟后继续,如果我们手动单击按钮,它也会继续 这是一件奇怪的事情。任何线索都可能是错误的,或者可能是缓存有问题 如果有其他方法,请让我知道 DocumentComplete事件中的代码C# WebBrowser控件卡住了,c#,winforms,webbrowser-control,C#,Winforms,Webbrowser Control,我正在构建一个将视频发布到用户域的应用程序。我使用了webbrowser控件。它运行得很好,没有错误。但当应用程序有更多视频要发布时,它有时会卡住 就像我在代码中单击submit按钮一样,它工作得很好,但当它这样做10次时,它可能会停止,有时会在一些延迟后继续,如果我们手动单击按钮,它也会继续 这是一件奇怪的事情。任何线索都可能是错误的,或者可能是缓存有问题 如果有其他方法,请让我知道 DocumentComplete事件中的代码 //Select HTML view
//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");
}
//选择HTML视图
if(webBrowserPostVideo.Document.GetElementById(“edButtonHTML”)!=null)
webBrowserPostVideo.Document.GetElementById(“edButtonHTML”).InvokeMember(“单击”);
//输入内容
if(webBrowserPostVideo.Document.GetElementById(“内容”)!=null)
{
webBrowserPostVideo.Document.GetElementById(“内容”).InvokeMember(“单击”);
webBrowserPostVideo.Document.GetElementById(“内容”).InvokeMember(“单击”);
webBrowserPostVideo.Document.GetElementById(“内容”).InvokeMember(“单击”);
webBrowserPostVideo.Document.GetElementById(“内容”).SetAttribute(“InnerText”,
youtubeVideos[SelectedVideo]。视频代码
.Replace(“,”).Replace(“,”).Replace(“,”).Replace(“,”).Replace(“,”);
}
//月后
if(webBrowserPostVideo.Document.GetElementById(“mm”)!=null&&youtubeVideos[SelectedVideo].PostingDateTime.Substring(6,2)!=null)
webBrowserPostVideo.Document.GetElementById(“mm”).SetAttribute(“值”,
youtubeVideos[SelectedVideo].PostingDateTime.Substring(5,2));
//发布日期
if(webBrowserPostVideo.Document.GetElementById(“jj”)!=null&&youtubeVideos[SelectedVideo].PostingDateTime.Substring(8,2)!=null)
webBrowserPostVideo.Document.GetElementById(“jj”).SetAttribute(“值”,
youtubeVideos[SelectedVideo].PostingDateTime.Substring(8,2));
//年后
if(webBrowserPostVideo.Document.GetElementById(“aa”)!=null&&youtubeVideos[SelectedVideo].PostingDateTime.Substring(0,4)!=null)
webBrowserPostVideo.Document.GetElementById(“aa”).SetAttribute(“值”,
youtubeVideos[SelectedVideo].PostingDateTime.Substring(0,4));
//邮局时间
if(webBrowserPostVideo.Document.GetElementById(“hh”)!=null&&youtubeVideos[SelectedVideo].PostingDateTime.Substring(11,2)!=null)
webBrowserPostVideo.Document.GetElementById(“hh”).SetAttribute(“值”,
youtubeVideos[SelectedVideo].PostingDateTime.Substring(11,2));
//邮政会议记录
if(webBrowserPostVideo.Document.GetElementById(“mn”)!=null和&youtubeVideos[SelectedVideo].PostingDateTime.Substring(14,2)!=null)
webBrowserPostVideo.Document.GetElementById(“mn”).SetAttribute(“值”,
youtubeVideos[SelectedVideo].PostingDateTime.Substring(14,2));
//输入视频标题
if(webBrowserPostVideo.Document.GetElementById(“标题”)!=null)
webBrowserPostVideo.Document.GetElementById(“标题”).SetAttribute(“值”,youtubeVideos[SelectedVideo].VideoTitle);
if(webBrowserPostVideo.Document.GetElementById(“发布”)!=null)
{
《睡眠》(2000年);
webBrowserPostVideo.Document.GetElementById(“发布”).InvokeMember(“单击”);
webBrowserPostVideo.Document.GetElementById(“发布”).InvokeMember(“单击”);
《睡眠》(2000年);
选择视频++;
webBrowserPostVideo.Document.GetElementById(“发布”).InvokeMember(“单击”);
}
您需要发布一些代码,以便我们可以进一步帮助您。我尝试按发布按钮3次,但这甚至不能解决问题