|
Thanks for the info.
It reminds me of several microprocessor families that use the lowest say four bits of an address for
such purposes when describing memory blocks, e.g. for paging tables, while they know these bits
in real addresses would always be zero due to the granularity of things.
|
|
|
|
|
Mike Dimmick wrote: 32-bit processors support 32-bit interlocked operations; 64-bit processors in 64-bit mode support 64-bit interlocked operations and that's it.
According to Wikipedia, the IA64 architecture supports 128-bit interlocked operations, so code which assumed the existence of an interlocked CompareExchange twice as wide as an object reference should be workable on all .net machines.
The DDJ article was a bit disappointing, since it failed to mention a general effective use of CompareExchange:- Create a new object.
- Begin loop:
- Latch old object reference
- Copy old object to new one, making any desired changes
- Use CompareExchange to store a reference to the new object in the old spot, if the old spot hasn't changed
- Loop until the CompareExchange succeeds.
Note that unlike a 'normal' spinlock, provided the time between latching the old reference and attempting to write the new one was short, the CompareExchange spinlock will seldom fail more than once per active CPU trying to write the variable. It never has to wait for another thread to do anything--merely for a chance to do its own thing without other threads disrupting it.
That general approach to CompareExchange works very nicely in a wide variety of situations. The two biggest weakness: (1) It's only practical for that are small enough to be copied quickly; the longer it takes to copy an object, the more likely the CompareExchange will be to fail and force a re-loop. (2) Allowing the reuse of objects from a pool opens up major complications; each operation thus requires getting a new object from the garbage collector, creating a performance bottleneck.
Adding support for CompareExchange on an 'Object-plus' structure would make it easier to allow safe reuse of objects from a pool. If each object kept a counter of how many times it had been reused and a copy of the counter were stored along with the object reference, that would eliminate the danger that a thread could attempt to use CompareExchange on an object which another thread had discarded (put in its pool for reuse) and reallocated.
|
|
|
|
|
I'll try to explain :
look this example :
Module
Module1
Sub Main()
Dim num AsDouble = 1.25
Console.WriteLine(Math.Round(num, 1, MidpointRounding.AwayFromZero))
num = 1.225
Console.WriteLine(Math.Round(num, 2, MidpointRounding.AwayFromZero))
num = 1.2225
Console.WriteLine(Math.Round(num, 3, MidpointRounding.AwayFromZero))
num = 1.22225
Console.WriteLine(Math.Round(num, 4, MidpointRounding.AwayFromZero))
num = 1.222225
Console.WriteLine(Math.Round(num, 5, MidpointRounding.AwayFromZero))
num = 1.2222225
Console.WriteLine(Math.Round(num, 6, MidpointRounding.AwayFromZero))
EndSub
End
Module
The output of this sample console application is :
1,3
1,23
1,223
1,2223
1,22222
1,222223
Is there something wrong ?
In my application I must use five decimal digits and this round method.
Regards
Andrea
|
|
|
|
|
|
The original message is here[^].
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
CICCIOLO69 wrote: num = 1.222225
Console.WriteLine(Math.Round(num, 5, MidpointRounding.AwayFromZero))
Um, use your brain just a little bit.
num = 1.222225
Console.WriteLine(num)
What answer did you get when you tried this?
Gary
|
|
|
|
|
Hi,
I am working on a windows service that monitor a path and does some upload based on the FileWatcher class. As per microsoft, it say that "More than one user Service may run within the same process". Therefore, i created two services (component classes) in my windows service project and added an instance of each to the service to run as shown below:
static void Main()
{
ServiceUtility initUtl = new ServiceUtility(Constants System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new exchangeRateFileWatcher(), new KYCFileWatcher() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun); }
However, i read that the second service will run only if the first one fails. Can you please tell me whether it is possible (and how) to run the two services within the same process (i.e exe)?
Thank you for your kind help
Carpe diem,
Krg
|
|
|
|
|
Don't cross post. It's considered rude and isn't going to help you get an answer any faster. While this is the original message, a response has already been posted to the one here[^].
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Ok scott.Sorry for that.
Carpe diem,
Krg
|
|
|
|
|
datastruct wrote: Sorry for that.
No worries, just letting you know.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Hi,
I have worked on .NET Framework 1.1.Now I want to work on .NET Framework 3.5. Can I migrate from 1.1 to 3.5 or firstly I have to go through .NET Framework 2.0/3.0?
Thanks in advance.
G Singh
|
|
|
|
|
Hi,
you can have multiple version of .NET FrameWork next to each other.
There is some dependency between Visual Studio and .NET versions.
2003 = 1.1,
2005 = 2.0,
2008 = 2.0/3.0/3.5
There is no need to upgrade one step at a time, you can go from 1.x to 3.5 directly,
all it takes is the Framework itself and an updated development tool such as Studio.
BTW: 3.0 and 3.5 really are extensions to 2.0, so the kernel of .NET is still at 2.0
|
|
|
|
|
|
Hi!
i want an article about .net exe files.
i want inject my code in this files (.net). how do i do?
i can inject my code in win32 PE files, but for .net exe file ???
please help me
Zo.Naderi-Iran
|
|
|
|
|
You cant inject code (well you can, but you will need to implement your own .NET profiler). Loading code from within your exe is easy though. Look at the System.Reflection namespace.
|
|
|
|
|
Is it possible to target .NET 2.0 using Visual Studio 2008, or will it force .NET 3.x?
Thanks in advance.
|
|
|
|
|
Rob Caldecott wrote: Is it possible to target .NET 2.0 using Visual Studio 2008
Yes. 2.0, 3.0, or 3.5
C# projects - Project properties/Application/Target Framework
C++ projects - Project properties/Common Properties/Framework and References
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, you can target .net 2.0 with VS2008.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hi to all,
can any body tell me where did u used delegate in your project or real time experience.
please help i am struggling for this question in interviews
This is haneef.............................................................
|
|
|
|
|
Try listing different skills on your resume.
|
|
|
|
|
Mostly used in event based environments. A wonderful usage scenario of delegates is in user interfaces. Its almost the same as C++ function pointers, but, they are type safe.
|
|
|
|
|
This asks where YOU used delegates. Not where I did, or Brady did. If you can't answer this question from personal experience, perhaps you should consider writing some samples.
|
|
|
|
|
I delegate all the time; life is much easier that way.
|
|
|
|
|
Here is a simple article that explains Delegates.
Article[^]
|
|
|
|
|
haneef wrote: i am struggling for this question in interviews
Maybe you ought to google it and learn about it then.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|