|
Okay, I think I was wrong. I can't find any of the references I thought I would.
Setting thread affinity in .NET does not do what I said. Nor have I found any mention of how to get the System attributes that include how many CPU's, or the speed.
|
|
|
|
|
I found it, System.Environment.ProcessorCount.
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
Actually, there is. And, I believe, you can set thread affinity, which specifies which real or virtual CPU your thread uses. I don't have the docs with me here now, but I'm pretty sure I just read this.
It's either in the Application namespace, or the _AppDomain namespace.
|
|
|
|
|
Hi CC#,
Starting with .NET 2.0 there is Environment.ProcessorCount
I dont know of any simple way to get more specifics (cores vs chips)
similar threads will get distributed over processors automatically, you would not
have to care about the details, unless you want maximum performance in special cases
such as two threads of type A plus two threads of type B running on 2 processors
(could by itself result in AA+BB or AB+AB which may behave slightly differently; in that
case processor affinity can be set with Thread.BeginThreadAffinity).
It may not be harmful at all to have more (identical) threads than there are processors,
so you might consider using 2 or 4 threads all the time, independent of processor count.
(Could be useful if, e.g. you also want to run on .NET 1.1)
Regards,
Luc Pattyn
|
|
|
|
|
Thank God Luc was here. Although I knew I had just read about all of this, I could not for the life of me find it.
|
|
|
|
|
Thanks, I got it.
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
I have a form which contains a tab control, which contains two tab pages.
On each tab page, there is a DataGridView, bound to it's own DataTable.
In the RowsAdded event handler for both DGVs, when the first row is added, I resize the columns to fit the data. My handler looks something like this:
private void dgvAllEvents_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)<br />
{<br />
...<br />
dgvAllEvents.AutoResizeColumn(0, DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader);<br />
}
This code works fine for the datagridview that is visible - that is, on the selected tab. However, the column does not get resized on whichever dgv is NOT visible - the tab page that is not selected.
The event is getting fired, I have confirmed that. But the column is not resized when the AutoResizeColumn method is called.
Is there an optimization here that prevents resize from being executed if the column is not visible?
Thanks for any insight you have here.
|
|
|
|
|
JoeRip wrote: Is there an optimization here that prevents resize from being executed if the column is not visible?
In the resize event handler check to see if the column is visible and if it isn't then return.
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
No, I think you misunderstand. I don't WANT to be optimal. I'm asking if the reason that my column isn't getting resized is that I am running into some existing .NET optimization.
|
|
|
|
|
I recall having seen several similar messages on DGV recently.
Seems to me there are some bugs...
Luc Pattyn
|
|
|
|
|
Those were probably me . I've been spending a lot of time in the DGV lately.
|
|
|
|
|
Hi,
I am using the Windows.Forms.Webbrowser component to display some text and graphics in my application, as it makes formatting quite easy, and I need flexibilty here. Everything that goes into it is set directly via the Code, not downloaded elsewhere.
As I need some interaction with this component, I have to use Javascript, which works fine so far, except one point: If the user has it disabled in Internet Explorer settings, it won't work in the component either.
Is there a way to programmatically allow its own application to use scripts? It should be, I guess, and I googelt a lot, found something with SecurityManagers etc, but I mussed have missed the point
So any help or code snippet is welcome
Thank you very much
Oh, and if you happen to know how to reference graphics from the included project's ressources instead of the program directory via the img-tag... would be a nice feature, too...
Tired of searching, frustrated of not finding ...
Thank you so much,
Eiko
|
|
|
|
|
Hi,
I successfully use the string.replace function.
Newstring = oldstring.replace(“*”,”~”)
Now I want to count the number of replacements made.
Thanks in advance!
Kermit
|
|
|
|
|
Hi,
String.Replace() or any other method wont tell you, but you could try a loop
int startPosition=0;
int n;
for (n=0; ;n++) {
startPosition=oldstring.IndexOf(searchString, startPosition)+1;
if (startPosition<=0) break;
}
before performing the Replace.
Luc Pattyn
|
|
|
|
|
Perhaps it can be done using a RegEx replace and a delegate. That would give you the opportunity to do something for each replacement.
A simple way (but not so effective if the string is large) is to create a string where you remove the character, and compare the lengths:
int cnt = oldstring.Length - oldstring.Replace("*", "").Length;
---
Year happy = new Year(2007);
|
|
|
|
|
before doing the replacement you could use RegEx.Matches(InputString,SearchPattern).Count.
BTW: RegEx.Replace is also a good method to do string-replacements.
- walter
|
|
|
|
|
Ok, I have to admit that I am stuck here.
My apps form has an icon set for it but I am tired of the compiled exe file not showing that Icon when I view the file in Windows explorer.
The problem is I can't seem to find anything that is really cut and dry on this. I see some stuff that seems to say you can't do it with the IDE and need to use the command line compiler but I have a hard time believe that...
Any takers out there?
I can't believe I am stuck on something so trivial...
|
|
|
|
|
Open the properties pages for the project and take a look under the Application tab (assuming you're using 2005), there should be an Application Icon property.
If you're using 2003 it's a similar thing in the Properties pages for the project.
|
|
|
|
|
Oh man I can't believe I looked right at that and missed it.
Thanks.
|
|
|
|
|
|
I have a program which run fine on my computer and on some client computer.
However, recently, it started to crash at launch time with a mysterious error as in the title.
After a bit of investigation it is probably a missing native DLL dependency in a Managed C++ library.
Investigating a bit more with depends I think the culprit is the following:
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.163_x-ww_681e29fb\msvcm80.dll
On my computer I have 2 versions of it:
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.163_x-ww_681e29fb\msvcm80.dll
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd\msvcm80.dll
But on the target computer I have only one version:
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd\msvcm80.dll
And "depends.exe" tells me that my ManagedC++ library is using the other version:
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.163_x-ww_681e29fb\msvcm80.dll
Although both version are quite old (06/2006 & 09/2006) (i.e. it's probably not a recent windows update) I think this is the problem.
Now why is the linker is linking to the newer version?
How can I link to the older version?
Any tips?
|
|
|
|
|
Welcome to the world of Win32 side-by-side assemblies.
The version of the assembly that you're going to use is specified in your manifest resources, which are generated from a manifest file. This is generated by Visual Studio and you should find a copy in your 'intermediate files' directory. For some reason, the version number that the manifest specifies is significantly older than the actual RTM version (8.0.50727.42).
When loading through a manifest, on systems which support Win32 side-by-side assemblies (XP, 2003 and later), the publisher can specify that a newer version is to be loaded. They do this by placing a policy file in %SystemRoot%\WinSxS\Policies, under the appropriate folder for the assembly. In the .policy file, they list how the bindings should be redirected. I have an 8.0.50727.163.policy file which says to redirect to 8.0.50727.163.
I also have assembly version 8.0.50727.91 - I'm not sure where this came from, it doesn't have a corresponding policy file. I think version 163 came with .NET 2.0 SP1. Visual Studio 2005 SP1 has yet another new version of the runtimes, but I'm not sure of the version number.
Win32 side-by-side assemblies are pretty complicated and you should ensure that you install the CRT through one of the supported methods: the vcredist_x86.exe file, or the CRT merge module (MSM). If you use the CRT merge module you must also use the corresponding policy merge module, or it will fail to load any version due to the manifest in the application asking for an older version than is on the system. That is, you should merge in both Microsoft_VC80_CRT_x86.msm and policy_8_0_Microsoft_VC80_CRT_x86.msm .
|
|
|
|
|
Thanks for this interesting food for thoughts!
I will look into that monday...
|
|
|
|
|
Dear Friends,
Could you please help me in this regard. What I need is this,
1. I want a .net User Interface to display office files(word, excel etc.).
So that I can put it in my web page to display office files. Similar to
DSO Framer control, but DSO Framer control is an activeX control made by using un-managed code.
But I need a similar UI, made by using .Net Framework. Doesnt itlook good. Could you please help me in this regard.
Thank you.
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
|
You know, it's hard to understand why you ask the same question over and over, especially when the last time you asked it is still visible.
I suggest you either write what you need, or tell your client that it doesn't exist. If it does, it costs money and people are trying to sell it. So, they want to find you, and if you can't find it with google, it probably doesn't exist.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|