|
Go to the project properties page and change the icon there.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi all,
After searching some text book and reference, I am not still certain
on how to use lock(this) in C# for sychronized access of the statements
inside the locked range. e.g.
lock (this)
{
statement1;
statement2;
}
why we need to put the "this" (refer to the object) after the lock keyword,
what will be the effect when putting other stuff instead of the "this" ?
Thanks
Patrick
|
|
|
|
|
Hi,
Generally the lock keywork in csharp is used to give the locking to any function.Suppose you are having one routine and the same routine is calling by two different object so if you are doing this things without lock your code may be unsafe but if you will use lock keywork if one object calls this method and upto finished up the method (or routine) another object can't be able to excess the same routine unless and untill first one completes the one.
and regarding answer of this keyword,that is use for saying that we are using current object not any other one.that's it.
regards,
montu3377
|
|
|
|
|
As the MSDN states: "The lock statement obtains the mutual-exclusion lock for a given object, executes a statement, and then releases the lock."
So the lock(this) statement obtains a mutual-exclusion lock for the current object of your class. If you use this statement in two or more methods of your class, these methods cannot be executed simultaneously by one object of your class.
But they can be simultaneously executed by multiple objects of your class as each obtains a mutual-exclusion for itself. This is no problem if you want to synchronize access to instance members. To synchronize access to class members you should use the following statement: lock (typeof(yourClass)) .
Finally back to the initial question: You can use any object in combination with the lock statement, but make sure it's always the same, cause otherwise the mutual exclusion won't work.
www.troschuetz.de
|
|
|
|
|
As a good practice, never use lock (this) or lock (typeof(Class)). As an example, if you use lock (this), and then someone uses lock (yourObject), you can add subtle deadlocks in your program.
Always declare a new, private object on your classes to lock on and you'll be safe.
Yes, even I am blogging now!
|
|
|
|
|
hello the worlde
can you help me show port pc
and open or clos the port
|
|
|
|
|
More information please...
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Like Alex said, LOTS more information.
What kind of ports? Serial, Parallel, I/O ports, TCP/IP ports, UDP ports, ... We need alot more detailabout what your trying to do and/or what your having a problem with, otherwise, there is nothing we can do to help you.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I need to translate a very large application to different languages and we will be using a custom tool to translate each form, reports, etc. We will not be using the localization features of .NET.
Is there an easy way for me to extract all the strings from the different assemblies and put them in an XML file for example?
Thanks!
Carl
|
|
|
|
|
If it was me, I'd write an app that uses regex to go over the cs files and make an xml file.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
i will use backpropagation, if i have a given number list of each number being 3 numbers ex. 123 should i make a network fully interconnected like this...
neuron1 neuron2 neuron3 <-input layer
neuron4 neuron5 neuron6 <-output layer
should i make a hidden layer and could someone help me please im confused, appreciate the help in advance
(this network will be using the next 3 digit number as training data)
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Hello,
I tried many things but I allways failed to send more than one variable using POST method.
Here is a sample code I use:
<br />
HttpWebRequest hR = (HttpWebRequest)WebRequest.Create("http://www.foo.org/bar.php");<br />
hR.Timeout = 5000;<br />
hR.Method = "POST";<br />
string postData="username=admin";<br />
hR.ContentType="application/x-www-form-urlencoded";<br />
hR.ContentLength=postData.Length;<br />
StreamWriter newStream=new StreamWriter(hR.GetRequestStream());<br />
newStream.Write(postData);<br />
newStream.Close();<br />
Can somebody help me to mod it to send more than one POST variable.
Regards.
|
|
|
|
|
|
I've got a section of code in my app that keeps track of how much time an employee has accrued, which equals out to 1.33 days of PTO per month. I'm trying to store the time accrued so far in an XML file. I have no problems writing to and reading from the XML file and all my values are correct. The problem I'm having is my calculation never amounts to 1.33, it goes from
1.32999999999997
to
1.3743333333333.
on the next run.
My calculation is
int TimePerDay = 1.33 / DateTime.DaysInMonth(DateTime.Parse(DateTime.Now.ToShortDateString()).Year, DateTime.Parse(DateTime.Now.ToShortDateString()).Month);
I save the difference of that calculation in the XML file, and then retrieve it again when the calculation is necessary. Here is the code:
int TimeCount = System.Double.Parse(xmlDoc.ChildNodes.Item(1).ChildNodes.Item(1).InnerText);
//the first time I retrieve this value, it will be initially set to 0.0443333333333333 the first time this code runs
TimeCount += 1.33 / DateTime.DaysInMonth(DateTime.Parse(DateTime.Now.ToShortDateString()).Year, DateTime.Parse(DateTime.Now.ToShortDateString()).Month);
xmlDoc.Save(Path);
Like I said the problem is that calculation never amounts to 1.33 - I have ran it many times in a for loop without ever converting it to a string value. The for loop eventually calculates to 1.33, and it stops at 1.33 and displays that fact in a MessageBox. I think I may be having a problem with the System.Double.Parse parser . . . anybody got any idea's?
__________________________________________________
Go ahead, code by the seat of your pants. It gives me more billable hours in the long run ...
|
|
|
|
|
I believe that Decimal is more accurate.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
unfortunately I get the same result when working with the decimal type . . .
If you put a time limit on this project, it won't ever get finished . . .
|
|
|
|
|
THe problem isn't with Parse. It's with how numbers are stored. You're using a division problem to generate a number which is infinitely long, 1.333333... A number like this is impossible to store accurately, so this is where your problem is created. In order to fix this, you'll have to round the results to the number of decimal places you need for accuracy. Also, use the Decimal type, not double. It's more accurate and all just about all the Math class methods support it directly with no conversions.
Math.Round[^] docs on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi,
i have a windows application developed, now i have created a deployment setup project for it. it includes the project output and dependencies and the .rpt files.
Well when i install it on the windows XP it runs smooth. i am using MS Access 2002 file format.
But when i install it on win 2000, I am not able to get the dataset from the database. The aaplication starts and gives me an error when i try to login. It says " Object reference not set to an instance", well i am using odbc DNS connection to MS Access.
I also tried installing odbc_net driver, but still same result, and also i thought it wont work as it is already available with the installation pack as .dll file.
What might be the problem. Do i need any drivers to install on win 9x and win 2000 OS.
Thanks
Imran.
|
|
|
|
|
Hi,
"Object reference not set to an instance" this type of error only occurs only and only if your object is not initiate anyhow so when object is not initilized so then only it gives error.
i think you need not to install any drivers for win9x and win2000 os becoz .net is more comfortable with any other.Yeah but check that .net framework is installed or not.That's must for every application.
regards,
montu3377
|
|
|
|
|
I want to use ADODB objects in c# but inside the aspx file not in the cs file.I can do it in vb.net like this:<%@ Import namespace="ADODB" %> at the top of page.(ADODB.dll and scripting.dll must be in the bin folder.) I can also import any other namespaces like:<%@ Import namespace="System.IO"%>.how can I do this in c#?thanks.
|
|
|
|
|
Hello,
does anyone know if (and how) it is possible to use speech-to-text for recognizing only numeric values?
Is there just a switch which i didn't find, or must i build an own grammar for this?
Thanks,
Wolfgang
|
|
|
|
|
I have tried to compile the requireifvalidator but keep getting an error that
csc is not a recoginsed interal or external program
|
|
|
|
|
This post appears to be article specific. Please post this question at the bottom of the page for the article. Thanks.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Is there a way to ambedd an exe, lets say notepad.exe into a mdi window? so when I start my application I have "notepad.exe" or any other exe inside a window of my form?
|
|
|
|