|
I take it you've never run Calibre[^]. Takes forever to load. Have no idea what it's doing, other than not starting promptly.
|
|
|
|
|
GenJerDan wrote: Have no idea what it's doing
Thread.Sleep(30000000);
|
|
|
|
|
Ah! A function call designed to dissuade all who are not seriously committed.
|
|
|
|
|
If you want a snappy GUI and/or you want to show some progress, you should limit the execution time of each of your GUI event handlers to say less than 30 msec. So having lengthy operations in a Form Load handler is no good; you should instead:
- launch a thread (possibly a BackgroundWorker ) in the Form Load handler;
- have that thread perform the lengthy operation (e.g. database access) and store results in some data structure;
- then use Invoke to have the GUI thread update the GUI, showing the newly acquired data, and probably enabling the Controls that now should be functional.
When the operation that needs to show progress is indivisible, you can't really show progress, all you can indicate is that time is progressing, so you should estimate a worst-case time span, and show a progress bar that advances at periodic points in time. A System.Windows.Forms.Timer is excellent for such purpose.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Look at this[^]. Yes, I wrote it...
|
|
|
|
|
hi sr159
Sometimes there's no practicable way to measure progress towards completion, using a simple mathematical formula.
In such cases, you need to estimate in advance how long the operation will take and then change the ProgressBar in accordance with the percentage time elapsed since inception. You also need to avoid moving the progress bar up to 100% until the overall task has completed.
take a look there[^]
|
|
|
|
|
In my web application , we are using Asp.net and C# , Some more method are give warning .
The warning it CA1822 Mark members as static
Its recomended to change static method.
But what i feel, if we are using static in more methods , its will go apart from the object
so memory its maintain all time even any request not comes. and if may access N number of user , Entire user request is try to using these same block of code( memory ). So may be happened performence issue . Or need to synchronize this code.
Please help me whats is happening exactly...
Thanks
|
|
|
|
|
anishkannan wrote: Please help me whats is happening exactly
All this means is that the method isn't accessing any instance members of the class (non-static fields/properties/methods). If you aren't accessing instance members and you are, say, passing in variables to your method the variables *might* be better expressed as fields or properties, improving the class design.
anishkannan wrote: But what i feel, if we are using static in more methods , its will go apart from the object
so memory its maintain all time even any request not comes. and if may access N number of user , Entire user request is try to using these same block of code( memory ). So may be happened performence issue . Or need to synchronize this code.
Marking the method can (not does) result in a measurable performance gain (see http://msdn.microsoft.com/en-us/library/ms245046.aspx[^]). It doesn't make it any less part of the class, it just decouples it from instances. If you think making the methods static will worsen performance or the static methods aren't semantically correct for your object, then you can suppress the warning perfectly safely:
#pragma warning disable 1822
public void Foo()
{
}
for individual warnings or add /nowarn:1822 to the compiler options. Personally I'd go for the individual warning unless it becomes a huge hassle.
|
|
|
|
|
Thanks for reply...
Warning disable is ok . Sorry, if any thing ask wrong...
Apart from that, Incase we use static function in page class. All private methods are static. if accessing 1,00,000 users at same time on the page. so all the user request are try to execute that same memory ( because of static method ). In this scenario which one is the best way avoid the static or can use
Thanks
|
|
|
|
|
Can use: each user gets a separate memory space and thus a separate static variable.
You cannot share information between users via a static variable or method!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
To add to Keiths answer, use
#pragma warning restore 1822 after the last method you want to stop the compiler complaining about.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
|
Hi, I have large XML, with many records. I would like to use SAX parser to read the xml and load it into datagridview and vice-versa. Please let me know whether it is possible. If yes, pls guide me. Thanks in advance.
|
|
|
|
|
|
|
In my pc there are few applications which sends request to server and receives response.
I want to make an application which will block few requests sent by those applications.
How can I do this ?
|
|
|
|
|
I'm chosing to assume you aren't doing this for malicious purposes. Please don't.
A decent firewall will allow you to stop a program from accessing the internet.
|
|
|
|
|
I want to make such firewall or want to hook into some process to do that.
I have downloaded NetDefender and Easy Firewall and few others. But after adding rules, none of them was able to block.
I also tried "Block All" option of NetDefender application. But it could not block.
Every time I receive a message something like "Could not register rule with network adapter". I am the administrator so there should not be any problem with permissions but I don't know why it is not working.
|
|
|
|
|
|
From the first string I need to build the second string, I know it can be done reiteratively but I'm wondering if there is a cute method of achieving this.
From this
"/100/101/201/"
I need to create this string - note the pipe delimiter.
"/100/|/100/101/|/100/101/201/"
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Define Cute?
You could split it, convert to integers, apply some lickety-split maths, reconvert to a string and concatenate.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Dunno if it's cute but I'd do a string.split and double-loop over the resulting array.
If the "records" are always fixed to 3 digits long you can do something like:
public string Foo(string original)
{
string output = original;
string remainder = outputstring.RemoveLastFourCharacters();
while (remainder.Length > 0)
{
output = remainder + "|" + output;
remainder = remainder.RemoveLastFourCharacters();
}
return output;
}
Obviously RemoveLastFourCharacters doesn't exist, I'd add a RemoveEndCharacters(int numberOfCharacters) type method or extension method. The other thing to consider is a StringBuilder , but only if the original string is likely to be long.
|
|
|
|
|
My mistake - # characters, it is basically a heirarchy id as a string. JAAN got the cutest result.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Bah! I did not haz TeH Codez!
|
|
|
|
|
I wouldn't call it cute, but it is clear:
string source = "/100/101/201/";
string resultWanted = "/100/|/100/101/|/100/101/201/";
string[] items = source.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
StringBuilder item = new StringBuilder("/");
StringBuilder sb = new StringBuilder();
string separator = "";
foreach (string s in items)
{
item.Append(s);
item.Append("/");
sb.Append(separator + item);
separator = "|";
}
if (sb.ToString() == resultWanted)
{
MessageBox.Show("OK");
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|