|
ok, i am going to try that, What I did find is I ran both computers side by side. put a break on refresh() and the paint call. In the one working you stopped at refresh then went immediately to paint call on resume. On the laptop it either took a =very long time to get to paint or you never get there and hang somewhere. Will try your suggestion now
|
|
|
|
|
when you say break do you mean "stop debugginh" I see no break on tool panel
|
|
|
|
|
sorry, I changed tools to expert and the break button showed up but I am having trouble finding the
the thread , however program breaks at 'application.run(new Form1()); and i don't think i should be there?
|
|
|
|
|
Joseph A Delinski Jr wrote: I am having trouble finding the
the thread
Did you mean you're having trouble finding the Threads window, or the main thread?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Threads window and main thread, both
|
|
|
|
|
I can infer, from one of your answers, that you are using WinForms, but in questions like this may I suggest you include in the original post a clear statement as to which of WinForms, WPF, DirectX, XNA, you are using.
best, Bill
"... Sturgeon's revelation. It came to him that Science Fiction is indeed ninety-percent crud, but that also—Eureka!—ninety-percent of everything is crud. All things—cars, books, cheeses, hairstyles, people and pins are, to the expert and discerning eye, crud, except for the acceptable tithe which we each happen to like." early 1950's quote from Venture Sci-Fi Magazine on the origin of Sturgeon's Law, by author Theodore Sturgeon: source Oxford English Dictionary on-line "Word-of-the-Day."
|
|
|
|
|
Yes I see your point, it is a Windows Form application. I believe the problem is that my
Laptop is to old to run program written on my desktop. The desktop framework has been upgraded with
the XNA as a possible feature. When I tried to do that (add XNA) to my laptop c# 2010 Express, I received an error that a sp# was needed and I couldn't get "that" upgrade to take. So I kinda give up and will see how my program runs on some friends newer machines. thanks for taking time to reply.
Joe
|
|
|
|
|
Hi,
I have 10 bool variables in a class. Instead of creating 10 bools, how to create a single bool and bit flags for remaining 9 bool variables inorder to efficiently use memory.
Can I have a code snippet in C# for this..
Thanks in Advance.
|
|
|
|
|
Why on earth would you need to do this? That's optimising beyond where you really need to go. A bool holds a negligible amount of memory, and the code you need to translate backwards and forwards from the bit flag would actually take up more memory than you would save in a single instance. Added to this that converting the bit flags takes clock cycles and you could end up with a less efficient program than just having nine bools.
|
|
|
|
|
I can think of plenty of reasons for this - none of which have directly to do with optimization (not for speed anyway).
For example,
- the flags are a field in a structure used in interop. (happens all the time)
- the flags are delivered as packed flags and later have to be passed on as flags. Saves a lot of setting up and tearing down to just leave them packed.
- when a switch over the packed flags (or a subset of them) is shorter and clearer than a massive tree of if's. (uncommon)
- when operations done on the flags can be done by short expressions of arithmetic and bitwise operations, and doing it manually with bools would create a huge mess. (ok this one is pretty rare, unless you write emulators)
|
|
|
|
|
But read the question asked. The wording there does not indicate that any of these are the reasons - hence why I asked why he was trying to do it.
|
|
|
|
|
Yes, his question doesn't really indicate anything, but your question sounds somewhat like it's never a good idea.
|
|
|
|
|
If a whole bunch of instances of the class are made then there could be a space saving. And if the instances are serialized and sent somewhere.
Regardless of concerns of "performance", grouping a bunch of related flags into an enumeration is a good design choice.
|
|
|
|
|
You may note that I carefully used the phrase "single instance". The point was to get the OP to think about whether or not they really needed to perform this optimisation.
|
|
|
|
|
Pete O'Hanlon wrote: to get the OP to think
You've been here long enough to know this is not possible
No comment
|
|
|
|
|
PIEBALDconsult wrote: Regardless of concerns of "performance", grouping a bunch of related flags into an enumeration is a good design choice.
The question implies unrelated booleans, as a compression technique.
Bastard Programmer from Hell
|
|
|
|
|
|
OP wrote: I have 10 bool variables in a class. Instead of creating 10 bools, how to create a single bool and bit flags for remaining 9 bool variables inorder to efficiently use memory.
It does.
Bastard Programmer from Hell
|
|
|
|
|
Does not -- they may very wel be related.
|
|
|
|
|
The fact that they "may" be related doesn't create a relation.
Bastard Programmer from Hell
|
|
|
|
|
Personally I don't think his question implies that much, so I'd like to hear the OP's explanation.. not that it looks like he's going to give one.
|
|
|
|
|
How about an enumeration?
|
|
|
|
|
Exactly.
Regards,
Rob Philpott.
|
|
|
|
|
I'd rather have 10 bulls bools than just 1
|
|
|
|