我对Windows Message Pump了解不多,但我想使用Message Pump触发事件.
1)当我的Web浏览器控件导航到某些网站时,它会创建不同的文档完成事件.一旦我在WebBrowser_Document_Completed()中拥有了我需要的东西,我想忽略所有进一步的文档完成.
我该怎么做?
2)如果我在Document_Completed(...)中显示MessageBox(),它会显示多个消息框,因此它在并行线程上运行,但是当我调试它时,我发现它总是在主线程上运行.
什么时候创建了另外两个线程?
3)此外,当我按下关闭它关闭窗口但该过程仍然在后台运行.我没有使用任何其他线程但我在调试时仍然看到另外两个线程.
我得到以下例外ProcessImage(bitmap1, bitmap2);
Unsupported Pixel Format of source or template image
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
public static double FindComparisonRatioBetweenImages(
System.Drawing.Image one, System.Drawing.Image two)
{
Bitmap bitmap1 = new Bitmap(one);
Bitmap bitmap2 = new Bitmap(two);
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);
TemplateMatch[] matchings = null;
matchings = tm.ProcessImage(bitmap1, bitmap2); // Exception occurs here!
return matchings[0].Similarity;
}
Run Code Online (Sandbox Code Playgroud)
我也managedImage从下面的代码传递到方法,但它仍然给出错误:
UnmanagedImage unmanagedImageA = UnmanagedImage.FromManagedImage(bitmap1);
Bitmap managedImageA = unmanagedImageA.ToManagedImage();
UnmanagedImage unmanagedImageB = UnmanagedImage.FromManagedImage(bitmap2);
Bitmap managedImageB = unmanagedImageB.ToManagedImage();
Run Code Online (Sandbox Code Playgroud)
我做了一个WCF服务,它包含一个方法字符串SaveVideoInformation()
此方法的目的是在未运行的情况下运行进程.以下是该方法的代码.
public string SaveVideoInformation(string ID, string videoName)
{
string Result = null;
try
{
Result = Insert(ID, videoName);
Process[] pname = Process.GetProcessesByName("AutoRunVideoWaterMarkingTook");
if (pname.Length == 0)
{
Result += " | Trying to run Process";
try
{
Process process = Process.Start(@"~\Debug\AutoRunVideoWaterMarkingTook.exe");
Result += " | Process Ran Successfully";
}
catch (Exception ex)
{
Result += " | Exception While Running the process";
throw new Exception("Unable to start Process);
}
}
else
{
Result += "|Process Already Running";
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用webbrowser控件在Facebook页面上发布图片和文本.
我在文本区域粘贴一个URL,当它获得缩略图时我发送密钥(ctrl + A).然后发送文本通过发送keys.Send(...)
所有工作正常,直到单击发布按钮它给出错误
"This status update appears to be blank. Please write something or attach a link or photo to update your status."
Run Code Online (Sandbox Code Playgroud)
我试图设置Textarea的所有属性,如标题,内部文本和占位符,我确信Text区域也不是null.
HtmlElement elementTextArea = null;
HtmlElementCollection elemss = webBrowser1.Document.GetElementsByTagName("textarea");
foreach (HtmlElement elem in elemss)
{
if (elem.GetAttribute("name") == "xhpc_message")
{
elementTextArea = elem;
break;
}
}
elementTextArea.Focus();
Print("\nSet Focused\n");
SendText(url);
webBrowser1.Update();
DoWait(4);
SendText("^(a)");
SendText(text);
webBrowser1.Update();
elementTextArea = webBrowser1.Document.GetElementById(id);
elementTextArea.InnerText += "\nINNER TEXT";
Print("\nAdded Inner Text ABCD\n");
//elementTextArea.SetAttribute("placeholder", text + "PLACEHOLDER");
//Print("\nAdded place holder text …Run Code Online (Sandbox Code Playgroud) Eclipse Android Emulator平均需要7分钟才能启动一个活动,相当长的时间一旦设置了模拟器,其他项目可以在相同的模拟器中运行,这需要花费更少的时间.有时当我启动eclipse并运行android项目时,它每次都会打开一个新的模拟器,而不是在同一个模拟器中安装项目.
我已经搜索了这个问题,我发现Single good Reason,Connection拒绝传感器端口是一个常见的问题我不确定,这才是真正的原因
我正在使用Eclipse for Windows,而不是Mac或Linux,之前的活动在我运行下一个项目之前已正确设置
帮助我弄清楚,这个问题背后的原因是什么,我怎样才能使它正常.
我已经使用Microsoft Expression Encoder附加了两个视频,这个东西很好用问题是,当我试图追加"wmv"以外的视频时,它给出了FileNot支持的例外情况
我在谷歌搜索但我无法找到解决方案.
private void button1_Click(object sender, EventArgs e)
{
MediaItem mediaItem1 = null;
Job job = new Job();
job.EncodeProgress += new EventHandler<EncodeProgressEventArgs>(job_EncodeProgress);
int count = 0;
//video url contains all urls of videos
foreach (string x in VideosUrls)
{
if (count == 0)
{
mediaItem1 = new MediaItem(x);
job.MediaItems.Add(mediaItem1);
}
else
{
mediaItem1.Sources.Add(new Source(x));
}
count++;
}
job.OutputDirectory = @"C://videoOutput";
job.Encode();
}
Run Code Online (Sandbox Code Playgroud)
有没有办法使用AForge.NET或Microsoft Expression Encoder,所以我可以编程方式将任何'mp4'视频转换为'wmv', …
我正在运行一个Windows表单程序,它在另一个线程上完成所有工作.一段时间后,UI冻结并停止响应.后台线程仍然正常工作(我可以从完成的工作中看到).
我有这个例外:
exe中类型为"System.IndexOutOfRangeException"的第一次机会异常
当我追踪异常线并再次运行时,我得到了这个:
线程
<No Name>(0x19b4)已退出,代码为0(0x0).
代码行运行正常,但它给出了一个System.IndexOutofRangeException.
MatchCollection tempcollection = Regex.Matches(document,
"(?<data>More information from(.|\\r|\\n)*?</div>)");
if (tempcollection.Count == 0)
{
return Result;
}
string ThisDiv = tempcollection[0].Groups["data"].Value;
// The above line shows exception in Output Window,
// otherwise it works fine and moves to next line.
Run Code Online (Sandbox Code Playgroud)
更新:我已经看到输出提供有关每个异常的信息,无论它是否被捕获,我认为这是冻结UI的原因,但事实并非如此.
我已经看到了与字符串生成器有关的问题,但是找不到相关的答案。
我的问题是“在这里使用字符串生成器是否明智?如果不是在此处明智地使用它”。
此方法将运行100000次。为了节省一些内存,我在这里使用了stringbuilder。但是问题是.ToString()方法。无论如何,我将不得不使用.ToString()method 创建一个字符串,所以为什么不初始化filename为string而不是StringBuilder。
internal bool isFileExists()
{
StringBuilder fileName = new StringBuilder(AppDomain.CurrentDomain.BaseDirectory + "Registry\\" + postalCode + ".html");
if (System.IO.File.Exists(fileName.ToString()))
{
return true;
}
else
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
所有库方法都使用字符串作为参数,而不是字符串生成器,为什么?我觉得我的概念很混乱。
我的问题有两个部分
1)我想为FileUpload Control分配文件名然后保存它,但问题是它是只读的
FileUpload1.FileName="ClientMachine\\Image1.jpeg";
FileUpload.SaveAs(ServerMachine\\Image1.jpeg);
Run Code Online (Sandbox Code Playgroud)
还有其他方法吗?
要么
2)我在客户端机器上有一个图像的完整路径.我想下载该图片.
我在谷歌搜索,但大多数问题是使用ajax,javascript,multipart-form.我没有任何这样的知识.我可以纯粹使用C#吗?
有时候Regex会卡在某些值上,尽管它会为大多数文档提供结果.
我正在谈论当它被卡住时的场景.
1- collection = Regex.Matches(document, pattern,RegexOptions.Compiled);
2- if (collection.Count > 0) //This Line
{
Run Code Online (Sandbox Code Playgroud)
我调试了解决方案,并希望在监视窗口中看到集合的值.我看到了大多数属性的结果.
Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation.
Run Code Online (Sandbox Code Playgroud)
后来它被困在第二线.
我可以看到正则表达式存在一些问题,所以它进入了循环.
问题: 我没有得到任何例外.这有什么办法可以在超时后获得异常,所以我的工具可以继续进行其余的工作.
Regex: @"""price"">(.|\r|\n)*?pound;(?<data>.*?)</span>"
Part of Document : </span><span>1</span></a></li>\n\t\t\t\t<li>\n\t\t\t\t\t<span class=\"icon icon_floorplan touchsearch-icon touchsearch-icon-floorplan none\">Floorplans: </span><span>0</span></li>\n\t\t\t\t</ul>\n\t\t</div>\n </div>\n\t</div>\n<div class=\"details clearfix\">\n\t\t<div class=\"price-new touchsearch-summary-list-item-price\">\r\n\t<a href=\"/commercial-property-for-sale/property-47109002.html\">POA</a></div>\r\n<p class=\"price\">\r\n\t\t\t<span>POA</span>\r\n\t\t\t\t</p>\r\n\t<h2 class=\"address bedrooms\">\r\n\t<a id=\"standardPropertySummary47109002\"
Run Code Online (Sandbox Code Playgroud)