c#-4.0

Visual Studio freezes on breakpoints

余生长醉 提交于 2020-01-04 13:05:33
问题 Since a week back I'm seeing a very annoying behavior from VS2010: As I'm debugging a project and the debugger stops on a breakpoint Windows freezes for almost ten seconds. I say "Windows freezes" because the mouse and keyboard are useless during this time period. The problem only happens as I debug a specific project and I've tried it on two diffrent machines with the same result. The project is WPF and I do hook the keyboard at one point (not the mouse though) but that code hasn't been

Set pixel on randomized position depending on brightness in the underlying image

大憨熊 提交于 2020-01-04 10:17:04
问题 I hope this is an interesting question for some people. I want to create some pixels on randomized positions on an image, but the randomizing should be depended on the brightness, so the possibility to create a pixel should be high on a bright part of the image and low on a dark part (but still possible). Lets take this image for example: I want to create a function SetRandomizedPixel which will get the bitmap and sets a pixel on a randomized position. The possibility that the pixel will be

Set pixel on randomized position depending on brightness in the underlying image

我只是一个虾纸丫 提交于 2020-01-04 10:14:50
问题 I hope this is an interesting question for some people. I want to create some pixels on randomized positions on an image, but the randomizing should be depended on the brightness, so the possibility to create a pixel should be high on a bright part of the image and low on a dark part (but still possible). Lets take this image for example: I want to create a function SetRandomizedPixel which will get the bitmap and sets a pixel on a randomized position. The possibility that the pixel will be

Get linq to return IEnumerable<DataRow> result

这一生的挚爱 提交于 2020-01-04 09:03:16
问题 How can I convert following SQL query to LINQ in C#? I don't need all columns from both tables and the result set should be IEnumerable<DataRow> Query: select c.level, cl.name, c.quantity from dbo.vw_categories c left join dbo.vw_categoriesLocalization cl on c.level = cl.level and cl.language = 'en' where c.level like '000%' and c.level <> '000'; Expected: IEnumerable<DataRow> result = ???? Thanks in advance.. 回答1: Here's how you would write the query: var query = from c in db.vw_categories

Access a span inside iframe using mshtml

我们两清 提交于 2020-01-04 07:18:51
问题 Im creating an IE BHO and trying to access a page that has multiple iframe tags. How to access the text in a span with id="messageText-txt" which is inside a specific iframe with name="isolatedWorkArea" and id="isolatedWorkArea" using mshtml. I tried the following options but none of them returns me the text. Any idea? Option 1: void BrowserEvents_NavigateComplete2(object pDisp, ref object URL) { SHDocVw.InternetExplorer currentIEWin = pDisp as SHDocVw.InternetExplorer; mshtml.IHTMLDocument2

Access a span inside iframe using mshtml

旧街凉风 提交于 2020-01-04 07:18:12
问题 Im creating an IE BHO and trying to access a page that has multiple iframe tags. How to access the text in a span with id="messageText-txt" which is inside a specific iframe with name="isolatedWorkArea" and id="isolatedWorkArea" using mshtml. I tried the following options but none of them returns me the text. Any idea? Option 1: void BrowserEvents_NavigateComplete2(object pDisp, ref object URL) { SHDocVw.InternetExplorer currentIEWin = pDisp as SHDocVw.InternetExplorer; mshtml.IHTMLDocument2

Combining PLINQ with Async method

邮差的信 提交于 2020-01-04 06:27:13
问题 I'm trying to combine my PLINQ statement like this: Enumerable.Range(0, _sortedList.Count()).AsParallel().WithDegreeOfParallelism(10) .Select(i => GetTransactionDetails(_sortedList[i].TransactionID)) .ToList(); With an async method like this: private async void GetTransactionDetails(string _trID) { await Task.Run(() => { }); } So that I can simply add an await operator in here: Enumerable.Range(0, _sortedList.Count()).AsParallel().WithDegreeOfParallelism(10) .Select(i => await

Tightest Byte Representation of YYYYMMDDHHMMSS?

人走茶凉 提交于 2020-01-04 06:18:09
问题 I need to pack string with a UTC datetime, using the smallest number of bytes/characters. I only need precision to the second. Using .NET 4.0, what would be the most space-efficient way to pack this down? Ticks doesn't seem all that small. All ideas appreciated. Thanks. EDIT: Thanks to Joel Coehoorn, the pack/unpack move is the best. Thanks! Here is some proof: DateTimeOffset nowStamp = DateTimeOffset.UtcNow; Console.WriteLine( nowStamp.ToString() ); // 9/9/2011 2:17:17 PM +00:00 Console

Select a row on mouse click in gridview

浪子不回头ぞ 提交于 2020-01-04 05:34:28
问题 I have a problem, I want to select a row in gridview on mouse click. My code is this : protected void PeopleGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';"; e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';"; e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.gvdetails, "Select$" + e.Row

How to use async in ASP.Net MVC for Mono

心已入冬 提交于 2020-01-04 05:27:11
问题 I am creating an ASP.Net MVC project in Mono using Visual Studio 2017 for Mac. I added the basic controllers, view, models, etc and it's working fine. However, as soon as make the Index method async I am getting the following error: System.InvalidOperationException The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Home/Index.aspx ~/Views/Home/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index