|
Devise a hashing algorithm for a snowflake. Shave ice as needed.
|
|
|
|
|
The problem is,
my application gets more requests that ticks can generate.
plus what if someone were to reset the system clock. It would then give duplicate numbers.
|
|
|
|
|
You're right about the system clock, but really how often does that happen?
So, you get requests faster than 100 nanoseconds. How often does this happen? If you notice, the code I presented makes sure that you get a new value just by comparing the lastvalue to the selected DateTime.Ticks and loops until you've got a new one.
Remember that the DateTime.Ticks property represents the number of 100-nanosecond intervals since 1 Jan 0001.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You're cripling his app with a busy loop !
And worst of all, adding more and faster CPUs wont help him in future.
|
|
|
|
|
ROTFL.
I did consider using a Sleep for 99 nanoseconds
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
What if the system clock was reset...
|
|
|
|
|
If you are using this in a production environment, the question is - when do you reset the system clock? In over 20 years of professional development, I can't think of a single time where the system clock needed to be reset - and bear in mind that I've done a lot of work with real-time monitoring systems where the system clock played a large part in monitoring/managing systems.
If you're that paranoid about the system clock, go with Luc's idea. It doesn't bother me as long as you get a system that you are happy with. That's all that matters.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Is it too late to change the requirements to return a GUID instead of an integer. Then you wouldn't have to worry a bout all of this crazy stuff...
One more idea, does the number have to be an integer... There is probably a faster way to do this, but it'll do more than 50,000 in a second from my test. Get the current ticks, then append an incrementing decimal to it.
private int currentRequest = 0;
private long uniqueNumber = System.DateTime.Now.Ticks;
public decimal GetUniqueNumber
{
get
{
return Convert.ToDecimal(uniqueNumber.ToString() + "." + newNumber.ToString());
}
}
Hogan
|
|
|
|
|
Hello,
I programmed my solution with the Environment.GetCommandLineArgs(); to get the arguments.
When i use the CMD command "path_to_exe/solution.exe file.ing", then it will work fine, my program strats up and opens the file.
Now i added the .ing extension to the registery and added the open command "path_to_exe/solution.exe %1". When i double click on a .ing file then i get error screen (the windows send report screen). What am i doing wrong?
please help!
|
|
|
|
|
'ing' is not recognize by window as extension.Window can understand extension which it knows.e.g bmp is extension for bitmap file.you can give bpm for bitmap.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
Thats right, but im insert the .ing in te registery (HK_CLASS_ROOT). that way windows will recognize the .ing and give it the icon what i want.
|
|
|
|
|
Add some logging code in there to see when the program dies -- in particular print out the command arguments to make sure you're getting the correct file name in the format that you're expecting.
|
|
|
|
|
The first thing my program does is geting the args then display it with a messagebox. but the message box never shows up. the program doesn't even show up, i get only the error page from windows
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
string[] args = Environment.GetCommandLineArgs();<br />
MessageBox.Show("args length: " + args.Length.ToString());<br />
<br />
|
|
|
|
|
1 - Change the command to "path_to_exe/solution.exe" "%1"
2 - Check that the .ing extension default value matches the registry entry that contains the open command.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thx you guys!!!
I found out the error. The error was that i read a conf file (with streamreader("temp/conf.txt")) before the openeing of the arg file.
Thats why the default dir get changed because the program first gets the location of the argument file, and the trys to read the temp/conf.txt in that dir. :S man i feel stupid...
thx again!!!
|
|
|
|
|
Don't feel stupid. We've all done things like this in the past.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
how do i check to see if an item is within a listbox, and if it is, to use it in an if statement to enable a button?
ie>> i want to check if an item is within a listbox, and if it is within the listbox, then to enable a button
Thanks
|
|
|
|
|
I am assuming you are trying to see if a string is within a listbox. You need to Iterate through the list collection, and do string comparision. If they are ==, then enable the button. Hope this helps.
<br />
string strSearchString = string.Empty;<br />
strSearchString = "SearchText";<br />
<br />
for(int i =0; i < myList.Items.Count; i++)<br />
{<br />
if(strSearchText == myList.Items[i].ToString())<br />
{<br />
btnMyButton.Enabled = true;<br />
}<br />
}<br />
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
|
You're welcome, happy to help
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Is there a way to show busy cursor (revolving or other type) in C# ?
Ex.
Processing Item 1 ...(*) <- flashing cursor
Processing Item 1 ...OK
I have seen this functionality in legacy console application, but don't know how to achieve this.
Many Thanks,
h.
|
|
|
|
|
//start processing
this.Cursor = Cursors.WaitCursor; //this will show the hourglass
//finish processing
this.Cursor = Cursors.Default;
|
|
|
|
|
this.Cursor applies to System.Windows.Forms ?
It does'nt work with System.Console class. If you find any method, please do post another reply.
Thanks for giving it a try.
h.
|
|
|
|
|
I have written some default values in Project Properties -> Settings at user level. I want to access these values in my coding. I am doing "Properties.Settings.Default" but somehow this is giving error.
Even the "Properties" is not recognised by compiler.
Something i missed to include, i don't know what????
How can i read the value from default project settings.
Gajesh
-- modified at 9:34 Wednesday 25th July, 2007
Gajesh
|
|
|
|
|
Hi,
In C# there is property NaN for Double, Single data types to store the null or empty values. If there any such property there for Integer?. I want to know very urgently.
Thanks in Advance.
Regards,
Prakash.A
Good Is Not Good When Better Is Expected
|
|
|
|