|
Of course it's thread safe. This is one of the mechanisms used to make things thread safe.
The documentation says that the waiting process does not get access to the code until you have ended the same number of locks that you started. That means that the system keeps track of the number of locks, otherwise the waiting process would get access to the code when you ended the innermost lock.
I tried to investigated the Enter and Exit methods of Threading.Monitor using .NET Reflector, but that did not reveal anything about the implementation. They are implemented internally in the CLR.
If you replaced the lock with something else, what is that then? Is that thread safe?
---
b { font-weight: normal; }
|
|
|
|
|
I can use a single lock I just had to reengineer my code to get rid of the nested lock.
Don't misunderstand I agree with you completetly.
On Monday I will throw your statement at him and see if it will satify him.
Guffa wrote:
The documentation says that the waiting process does not get access to the code until you have ended the same number of locks that you started. That means that the system keeps track of the number of locks, otherwise the waiting process would get access to the code when you ended the innermost lock.
|
|
|
|
|
Greetings All,
I posted this message in VC forum, but didnt get feedback, may i could get feedback here.
I do boolean operations on regions acquired from paths, after the boolean operations i would like to set resulting region to a path.... I do not know if this is possible and leaning towards that it is not. has anyone tried this before?
Thanks in advance
Sincerely,
Max Pastchenko
|
|
|
|
|
I found out that it is not pissible.
I guess a solution would be simple storing that region and diplaying it long with paths on a bitmap.
Sincerely,
Max Pastchenko
|
|
|
|
|
I have a for loop that labels tick marks on a graph axis. I can't make it do what I want.
I want this:
| | | C | | |
-3.0 -2.0 -1.0 +1.0 +2.0 +3.0 etc..
I keep getting this:
| | | C | | |
-3.0 -2.0 -1.0 +0.0 +1.0 +2.0
My loop uses a DrawLine(x1, y1,...) to draw the ticks
It also uses a DrawString(f.ToString("f1"), ....) to draw the numbers
I then increment the float for the next iteration.
I've tried a few control structures "if else..." but keep ketting similar results...
Any ideas? Thanks in advance
|
|
|
|
|
Message didn't format the way it was written. Each tick should line up over each float with "C" as the (0,0) coordinate. I want it NOT to label the "0.0" at the origin but then label the +1.0 .
|
|
|
|
|
Use an integer for the loop counter instead of a float. A float value seldom is an exact value, so if you compare it to 0.0 it might not say that they are the same, as the value in your variable might actually be something like 0.0000000000000001.
---
b { font-weight: normal; }
|
|
|
|
|
I have a situation where I have three separate C# class objects that all have the same properties and methods so their signatures are the same in all respects except for the class name (I am writing a code generator for personal use with each class representing a different design pattern).
There is also a core class which operates as a control point to call each class depending on which design pattern is chosen. The challenge I have is that it would be extremely cumbersome and complex in the control class to populate the many properties and call the many methods separately for each design pattern class so I was attempting to declare a generic object type first, instantiate the proper pattern class inside a switch block, assign the instantiated pattern class to the generic object type outside of the switch block, and finally populate all the necessary properties and call all the necessary methods using the generic object type class.
The result in many different attempts to do this always ends up with the compiler returning an error message saying the generic object type class does not contain the properties or methods specifed and I am looking for a way to make this happen.
Psuedo-code for what I am trying to do:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Declare generic object type
object cNetPattern;
// Determine design pattern requested
switch(m_iNETDesignPattern)
{
case (int)eNETDesignPattern.TDSTraversal:
// Instantiate TDS Traversal design pattern class 'clsPattern_1' here
break;
case (int)eNETDesignPattern.Collection:
// Instantiate Collections design pattern class 'clsPattern_2' here
break;
case (int)eNETDesignPattern.ClassProvider:
// Instantiate Class Provider design pattern class 'clsPattern_3' here
break;
}
// Assign specific class type object to generic object type
cNetPattern = clsPattern_n; // Where 'n' is the specific pattern class object instantiated above
// Populate properties and call methods
cNetPattern.bProperty1 = m_bProperty1;
cNetPattern.Method1();
...many, many more properties and methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOTE: As mentioned all three specific design patterns have the same property and method signatures.
Any help would be grealy appreciated!
Dennis M.
|
|
|
|
|
Dennis,
Your explanation was a little confising, but is this what you're trying to do?
object X;
switch(thang)
{
case a:
X = new X1();
break;
case b:
X = new X2();
break;
case c:
X = new X3();
break;
}
X.Property1 = 13;
X.Method42();
...
If so, put all the properties and methods in X and then have X1, X2 and X3 inherit from X. I assume you'll also have to overload X's methods in X1, X2 and X3. Just because two classes share the same signatures doesn't mean they can be interchanged. It's the interface that matters.
Good luck,
Andrew
|
|
|
|
|
Yes your example is exactly what I am trying to do. So that means that I would have a base class of X with all properties and methods specified, and in my case I would have all the methods in the base class empty and overrideable so that the derived classes (X1, X2, X3) could provide thier own logic by overriding the base class method. This sounds like it will work for me which I will try asap - Thanks for the reply!
Dennis
|
|
|
|
|
I have a DataTable with composite key bounded to the DataGrid.
So when the user inserts some data which violates the constraint, an exception is thrown.
What is the right place (event etc) to do any additional custom Validation?
Another problem is the the message that DataTable throws is not user friendly? How can I stop it and give a more meaningful message?
The message I got is
"Error when committing the row to the original data store"
|
|
|
|
|
You can add and event handler for the RowChanging event of your datatable.
|
|
|
|
|
Thanks a lot for the reply.
I tried this before, but I want the DataGrid to do the actual validation but I want to give a custom message. But in case of the solution you have specified, the DataGrid itself shows a MessageBox with a message which is not use friendly.
|
|
|
|
|
does anyone out there know how create an autoupdate functionality in a windows Application. Lets say on the client a window pops up showing an update is ready for download.
|
|
|
|
|
|
|
you can also try reading this
http://msdn.microsoft.com/smartclient/understanding/windowsforms/2.0/features/clickonce.aspx
http://msdn.microsoft.com/msdnmag/issues/04/05/clickonce/default.aspx
There is another article on msdn about clickonce, i cant seem to find it.
even though click once is associated with VS 2005. November is only a few months away.
|
|
|
|
|
Hi,
This is really taking toll of my project.
I have a windows service which copies files from different remote servers to local hard drive and process them.
The problem due some network issues service gets hang while coping the files.
Do we have good copy utility in .NET which can help, I am using FileInfo.CopyTo method.
Also please note I can not use FTP as our company does not allow to.
Thanks,
Nitin.
|
|
|
|
|
Hi Buddy i am trying to do the same job but i am in ver basic level. So i have request to you if you could send me you artical, demo or code so i know how to do this job.
Please
Muhamad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
I have a fairly robust Windows Forms application in which I allow the user to continously create and delete DataGrid objects. I have a number of references pointing to any one DataGrid object. Even after all references are nulled out to any one DataGrid object (and it is Removed from Forms.Controls), the memory used doesn't seem to be garbage collected. Even if I call GC.Collect.
I can see this because memory usage in the Windows task manager just grows and grows until the application slows to a halt. I even included a finalize method for the DataGrids, and it never gets called.
Obvious I still have some "dangling references" to the DataGrid objects I am creating.
My question...Is there any way to see (in the debugger?) a list of all the references still pointing to a single object?
Thanks!
Mark
|
|
|
|
|
DataGrid need finalized before the GC will collect them, and finalization is a very low priority thread. To force them to be cleaned up ASAP, call Dispose when you're finished with them.
|
|
|
|
|
Thanks Dan. At your advice, I tried that, but it seems to have no effect. In reality, I am using a TrueDBGrid from Component One, which functionally works like a .NET DataGrid. I am calling Dispose against it when I am done with it.
I overrode the finalize method of the grid and included a MessageBox inside. Every one of the discarded, disposed grids DOES get garbage collected when I close the application. I need them to get garbaged collected during the app.
Anyone have any other ideas?
Thanks!
Mark
|
|
|
|
|
I wouldn't depend on Windows Task Manager, IMO, the performance counters (#Bytes in All Heaps..) are much more reliable.
If you're sure you're leaking memory, CLR Profiler[^] is a very handy utility that allows you to track objects in the managed heap.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Wow! I didn't know something like CLR Profiler existed! Thanks!
I will give it a try and post back with the results.
Mark
|
|
|
|
|
how do u terminate a void function? like break...
|
|
|
|