|
Just curious, where that you get that value? (this is not a "citation needed!", I just like benchmarks)
|
|
|
|
|
I think he just threw it up in the air (think about it )
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
I would agree, thou it's a bit of a tricky one. Although both are costly, 'Throwing Exceptions' will benefit the application (i.e. errors will be handled and therefore must be an improvement). I think the problem with the question is the use of the word 'optimize' as that gives the impression of improving performance. I guess in this case it's meant to mean improving the application as a piece of software.
Just out of interest, what was the third option?
EDIT:
Oh, which should not be used... Well then surely that's an invalid question.
Am I right in saying that the Q&A is suggesting that you should use 'Frequent Boxing and Unboxing' to optimize a windows application?! Why the hell, in any situation, would adding more work optimise anything. The only thing that made 'Throwing Exceptions' valid is that it has benefits.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
"Which three of the following should not be applied to optimize a windows application"
What I get from this is: What will slow down an application.
Now there were 5 possible answers, I dont actually remember the rest but basically they say that only the Throwing exceptions one is correct and im saying that boxing/unboxing will also "not optimize an app".
Thanks for your thought guys, the voices in my head stopped for a second there.
|
|
|
|
|
|
You're not crazy. Unless you're misusing exceptions for general control flow (instead of exceptional control flow), (un)boxing is more likely to be a performance problem. Exceptions are not supposed to happen - so it doesn't matter that they're slow.
|
|
|
|
|
The application I am writing, the user has to right click on the file and tell the file to Run As and login with a admin account. Is there a way to tell if the user that is logged in running the program is a admin or not? This is in XP not vista.
|
|
|
|
|
Hi,
this is a snippet I once used, it shows "User" or "User, Administrator" IIRC:
List<string> roles=new List<string>();
try {
Thread.GetDomain().SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal wp=new WindowsPrincipal(WindowsIdentity.GetCurrent());
foreach(object roleName in Enum.GetValues(typeof(WindowsBuiltInRole)))
if (wp.IsInRole((WindowsBuiltInRole)roleName)) roles.Add(roleName.ToString());
} catch (Exception exc) {
log(exc);
}
log("Windows role = "+string.Join(", ", roles.ToArray()));
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I've added a setup project to my solution and added the project output from a windows App. The install worked fine.
I then changed 2 settings in my config file from User settings to Application settings. Rebuilt the projects and tried to re-install. The config file did not get updated in the installed version. I'm using vs2008.
I even tried removing the setup project and creating a new one. But, the old config was still installed! How is the Setup Project still referencing the old config file? I click on the project output in the setup project and select "Outputs". This gives me the directory to the config file. I've checked this and it does point to the correct version of the config file. So I'm confused as to why the config file isn't changing.
Any ideas?
Thanks.
|
|
|
|
|
Sorry for replying to my own post.
I've tried this again in anther solution. Just added a Win App and a setup project to the solution. I added some Application settings to the app.config file and installed. Then Changed the Application settings to User Settings and re-installed. The config did change on the second install so now I am really confused.
The only thing that I can see that I am doing differently in my main solution is Changing the Assembly Version number. Would this affect the Config File not being correctly installed when using the Setup Project?
|
|
|
|
|
Hi,
I know I'm not getting much input on this but I've just deleted the Setup project and added again but with a different Project name and this worked. This has got me over the problem short term but I'm worried what will happen when I need to upgrade my project.
Last attempt but has anyone got any ideas? I've tried changing the version number of the setup project and setting "RemovePreviousVersion" to true but everything I tried just didn't work.
|
|
|
|
|
If I change a static class variable in one application instance and I have multiple instantiated applications using the same dll will I be able to see that specific modification from one of my other applications? I'm thinking yes but I'd like to know for a fact. Any words of wisdom?
Thanx
|
|
|
|
|
No. Instance data as well as static data only exists inside a single process. In order to share data amongst applications, you must take special steps and use one of many available mechanisms, e.g. memory-mapped files.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Can you maybe elaborate on these mechanisms?
|
|
|
|
|
There are lots of mechanisms; whatever your need may be, a few of them will fit well.
Search for "interprocess communication", and read the documentation, there is plenty of it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
This isn't fully correct...
there is a method.. not for the feint of heart..
you can go into the .prj (or.sln) file and make a manual reference to the
location of the dll that you compile from the static class
(for each project that you want to reference that particular dll)
I've never done it (needed to do it) myself but I've heard about it...
come to think of it you can basically do this by add>existing project> your_dll.sln
then whenever you modify your_dll.sln it will be compiled into your other programs..
did I ramble.. sorry.
|
|
|
|
|
ely_bob wrote: whenever you modify your_dll.sln it will be compiled into your other programs..
you can add the same code to several processes, that does not magically make them share some data; unless the code you are sharing is taking care of interprocess communication, but then you don't need a DLL for that.
ely_bob wrote: did I ramble
a bit (if not a byte)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Remoting the static instance is an option. Remoting offers out of the box support for singletons.
|
|
|
|
|
Hi
I’ve bean trying to create my own stile for the comboBox but something is going wrong.
The text box is drawing black. Does any one know how to fix this ???
Roy
|
|
|
|
|
Possibly it is reacting to your spelling and punctuation.
precious roy wrote: I’ve bean been trying to create my own stile style for the comboBox but something is going wrong.
The text box is drawing black. Does any one know how to fix this ??? ?
Without more information as to what your code is doing to make it draw black, I really can't say...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
ok well here is the code.
Office 2007 Button[^]
i was trying to combine the two and it works half :}
and this is the code i have.
hmm its a bit to long to post here... but here is the draw
internal void onDrawControl(Graphics e)
{
recBounds = this.ClientRectangle;
Rectangle m_BrushSize = new Rectangle(0, 0,
this.Width, this.Height / 2);
for (int i = 0; i <= 40; i++)
{
LinearGradientBrush myLinearGradientBrush1 = new System.Drawing.Drawing2D.LinearGradientBrush(m_BrushSize, Color.FromArgb(i, 255, 253, 235), Color.FromArgb(i, 255, 235, 182),
90);//top item
LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush(m_BrushSize, Color.FromArgb(i, 255, 214, 56), Color.FromArgb(i, 255, 232, 167),
-90);//down item
myLinearGradientBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.TileFlipXY;
myLinearGradientBrush1.WrapMode = System.Drawing.Drawing2D.WrapMode.TileFlipXY;
e.FillRectangle(myLinearGradientBrush, 1, this.Height / 2,
this.Width - 2, this.Height / 2 - 1);//down
e.FillRectangle(myLinearGradientBrush1, 1, 1,
this.Width - 2, this.Height / 2);//top
//Draw Border
Brush brsBorder = new SolidBrush(Color.FromArgb(191, 167, 121));
Pen pnsBorder = new Pen(brsBorder);
Brush brsDot = new SolidBrush(Color.FromArgb(233, 223, 159));
Pen pnsDot = new Pen(brsDot);
e.DrawRectangle(Pens.White, this.ClientRectangle.X + 1, this.ClientRectangle.Y + 1, this.ClientRectangle.Width - 3, this.ClientRectangle.Height - 3);
e.DrawLine(pnsDot, this.ClientRectangle.X, this.ClientRectangle.Y + 1, this.ClientRectangle.X + 1, this.ClientRectangle.Y + 1);
e.DrawLine(pnsDot, this.ClientRectangle.X, this.ClientRectangle.Bottom - 2, this.ClientRectangle.X + 1, this.ClientRectangle.Bottom - 2);
e.DrawLine(pnsDot, this.ClientRectangle.Right - 1, this.ClientRectangle.Bottom - 2, this.ClientRectangle.Right - 2, this.ClientRectangle.Bottom - 2);
e.DrawLine(pnsDot, this.ClientRectangle.Right - 1, this.ClientRectangle.Y + 1, this.ClientRectangle.Right - 2, this.ClientRectangle.Y + 1);
e.DrawLine(pnsBorder, this.ClientRectangle.X + 1, this.ClientRectangle.Y, this.ClientRectangle.Right - 2, this.ClientRectangle.Y);
e.DrawLine(pnsBorder, this.ClientRectangle.X, this.ClientRectangle.Y + 1, this.ClientRectangle.X, this.ClientRectangle.Bottom - 2);
e.DrawLine(pnsBorder, this.ClientRectangle.X + 1, this.ClientRectangle.Bottom - 1, this.ClientRectangle.Right - 2, this.ClientRectangle.Bottom - 1);
e.DrawLine(pnsBorder, this.ClientRectangle.Right - 1, this.ClientRectangle.Y + 1, this.ClientRectangle.Right - 1, this.ClientRectangle.Bottom - 2);
//////////////////////////////////////////////////////////////////end Border
myLinearGradientBrush.Dispose();
myLinearGradientBrush1.Dispose();
brsBorder.Dispose();
brsDot.Dispose();
pnsBorder.Dispose();
pnsDot.Dispose();
}
|
|
|
|
|
I just tested it using the original code and just replace the method onDrawControl with yours, it works also fine...
|
|
|
|
|
Yes i know it works but when inherating from a ComboBox the text box is black.
|
|
|
|
|
I have created my own class names Box.cs. Now I want to borrow the mouse Event which I see in most controls found in .Net and apply it also to my box so that If I click my box an event is triggered
|
|
|
|
|