|
Thanx for all,
I solve the also,
it is Programing BUG......
a loop enter in the Infinite state, so this Problem occur,
I think it is not a DotNET bug....
Any Discussion or Comments are highly appreciated.....
Sajjad
|
|
|
|
|
imshally81 wrote:
I think it is not a DotNET bug....
That was immediately obvious to almost everyone, I think.
Never assume the bug is not yours, until you've established that it cannot possibly be. Even then, don't be too sure.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi.
I have to create some kind of event tracker class, which should register hooking handlers to events. I need a method
RegisterEvent (object target, Delegate handler)
in which I add handler to event (target). Target is probalby System.MulticastDelegate. Is it possible to do that, even when I don't know the event name? I want to avoid changing this method to
RegisterEvent(object target, Delegate handler, string eventName).
All examples that I've found use GetEvent(name) from reflection, and than EventInfo.AddHandler(..)
Pszat
|
|
|
|
|
I'm not sure what exactly you want. How can you subscribe to an event without having anything to identify it?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
No idea how to do it if target is a delegate, but here is a way to add a handler to all the events in an object that are the same type as the handler:
public void RegisterEvents(object eventSource, Delegate handler)<br />
{<br />
if (eventSource == null || handler == null)<br />
{<br />
return;<br />
}<br />
<br />
EventInfo[] events = eventSource.GetType().GetEvents();<br />
<br />
if (events.Length > 0)<br />
{<br />
foreach (EventInfo eventInfo in events)<br />
{<br />
if (eventInfo.EventHandlerType == handler.GetType())<br />
{<br />
eventInfo.AddEventHandler(eventSource, handler);<br />
}<br />
}<br />
}<br />
}
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
when i want to handle the event from a remote object there is an error telling me Can Not find ... assembply.
the object can be referenced but not events.
i really appreciate any help since i couldnt understand how to solve it.
|
|
|
|
|
show me your codes , maybe i can help you
you can mail to gavin@m165.com
|
|
|
|
|
A new version of Portable.NET, the Free implementation of Common Language Infrastructure, is finally available. The new version features numerous performance improvements, fixes for WinForms and Xml, and many other changes - read the full list of changes. The new release also brings a new runtime package (at this stage for Windows systems only) - at just under 2MB its goal is to solve the problem of redistributing large runtimes. More details.
Full Portable.NET SDK for Windows will be available by the end of the week, so check back for updates
|
|
|
|
|
Subject says it all...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can anyone tell me how to schedule a nightly team build on VS 2005 foundation build server? Also, what should a release build do besides copying the compiled files to production server?
|
|
|
|
|
|
Hi,
i got a (kind of graphic editor) c#.NET application where i needed to implement double buffering (using a memory bitmap).
now i got a real problem in my MouseMove handler when moving objects cause i gotta copy the whole bitmap to screen (using Graphics.DrawImage(...) ) on every MouseMove event (~ 1280 * 1024 px).
the problem is that GDI+ is soo f***in slow and takes about 50 millisec to render one memory bitmap to screen (i tried the same using c++, mfc and thus GDI32 and it takes about 6 to 8 msec / to copy a bitmap to screen [BitBlt(...) ]; and both times i've been using the QueryPerformanceCounter API to get an accurate execution time interval)
so am i missing anything or is GDI+ + c#.NET REALLY soooo slow?
is there ANY other way than porting the whole code to use imported GDI32 APIs ?
thanks alot!
daniel.
|
|
|
|
|
Are you using DrawImageUnscaled ? That's faster.
Other than that, why on earth do you need to copy the whole bitmap to screen every time you move the mouse ? Sounds like you need to optimise your code ( for example, just invalidate the area you're changing ). I've written paint programs in C# that refresh the screen on mouse move, and they work just fine.
Of course, it is still true that if you want speed, you should be using C++.
Christian Graus - Microsoft MVP - C++
P.S. It's also true that you can pinvoke GDI if you really want to.
|
|
|
|
|
i'm not using DrawImageUnscaled, yet. thanks for the hint, i'll try this!
>Other than that, why on earth do you need to copy the whole bitmap to screen every time you move the
>mouse ? Sounds like you need to optimise your code ( for example, just invalidate the area you're
>changing ). I've written paint programs in C# that refresh the screen on mouse move, and they work
>just fine.
well...you're right, i dont need to copy the whole bitmap on every MouseMove, but what if the user
creates an object that fills quite the whole screen and wants to move it? or when he scrolls the
working area? the graphics should be displayed smoothly regardless of the object's size...
no question that only invalidating the area i'm changing would be nice optimization, but it should
also work without, cause it is still possible that i'm required to copy (quite) the whole screen...
|
|
|
|
|
I'm doing code that shows an image on the full screen and lets the user click and drag it. It's not as smooth as I would like, but it's acceptable. At the core, C# is indeed slower thant C++, that's a part of the decision to use it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
that's a part of the decision to use it.
...if it only would have been MY decision...
anyways, thanks for your help!
|
|
|
|
|
Christian Graus wrote:
At the core, C# is indeed slower thant C++
I don't want to start a big discussion but that's not true. Surely GDI+ is slower than GDI32 but you can improve the performance by calling the APIs directly. The speed will then be equally to C++ but you pay this off by having to use unmanaged stuff (which is not so nice in C# compared to C++).
|
|
|
|
|
Robert Rohde wrote:
you can improve the performance by calling the APIs directly.
Robert Rohde wrote:
by having to use unmanaged stuff
So, to recap - C# is as fast as C++ if you use it to call C++ APIs, so the work is done by C++ code ? That sounds like the 'VB6 is as good as C++' argument all over again.
Don't let the C++ MVP fool you, I use C# almost exclusively nowadays. But I would maintain that C++ is the faster language, for now. Making C# faster by getting it to call native methods kind of defeats the purpose, why not just use C++ ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
So, to recap - C# is as fast as C++ if you use it to call C++ APIs, so the work is done by C++ code ?
Now that's an real unfair statement. Unless we have some real innovative processors at some point managed code HAS to call unmanaged code - or how do you think a processor should understand it. If it is within the framwork or directly in your app by API calls does not make much difference (besides the matter of personal taste - I prefer MS doing this stuff ). This is true for every .NET class. The problem with GDI+ (like many other things in .NET) is that it doesn't reveal the power of the whole underlying windows APIs.
|
|
|
|
|
ok, i heard that often before. nearly everybody tells me c# isnt (much) slower. but WHY is it really a lot slower when i check this myself?
as i really wanted to know now, i tried it myself (and feel free to do so, too) and took both (c++ of VS 6.0 and c# of VS.Net 2003) and let them calculate fibonacci numbers up to n=40.
MY results are:
VS6.0 & c++: 2.580 seconds
VS.Net 2003 & c#: 5.019 seconds
(results should be accurate down to less than 1 msec)
so why does c# require almost 2 times the time c++ does?
PLEASE check this yourself, let me know if i'm right and also tell me if i'm not correct...
i'd really like to know the truth and not just rely on some weird microsoft benchmarks.
both tests were build in "Release" configuration, without debug information and with code
optimization a.s.o.
the code was (both times called in first constructor and immediatly after each other, so u can't say it depends on any other circumstances like free RAM or things like that....)
c#:
private long fib(long n)
{
if (n < 2)
return n;
return fib(n-1) + fib(n-2);
}
c++:
long fib(long n) {
if (n < 2)
return n;
return fib(n-1) + fib(n-2);
}
both times the result was 102334155. so what am i doing wrong? why is c# so much slower for me than c++? just because of the excessive recursion and stack usage? should i try an example concerning
"only" function calls or memory access? or check the speed of _dynamic_ array operations?
second thing i don't understand is (and thx for the hint; i really need any solution and thus try this): you're saying c# and calling GDI+ APIs directly is as fast as c++; ok, but the GDI+ code remains the same wheather u call it directly or not. so if it's not GDI+ it has to be c# (what else?)... so isn't this in conflict with your first statement???
this should really be no offense, i only wanna know for sure how things are...
daniel.
|
|
|
|
|
l3st4rd wrote:
so why does c# require almost 2 times the time c++ does?
PLEASE check this yourself, let me know if i'm right and also tell me if i'm not correct...
Any .NET code gets compiled from MSIL the first time it is called. To do a proper benchmark, you need to generate the sequence twice, and time the second pass. Every function is compiled when it is first called.
l3st4rd wrote:
you're saying c# and calling GDI+ APIs directly is as fast as c++;
No, I said GDI. GDI is the way things are handled under the hood. HBITMAPs and BitBlt to HDCs.
l3st4rd wrote:
this should really be no offense, i only wanna know for sure how things are...
Not at all offended, glad to help.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
(well this post was primary addressed to Robert R. cause he did decline that c# is slower than c++ [what i can hardly belive], but anyway...)
Christian Graus wrote:
Any .NET code gets compiled from MSIL the first time it is called. To do a proper benchmark, you need to generate the sequence twice, and time the second pass. Every function is compiled when it is first called.
but anyways, i got some things to say about this:
1st) does any end-user take care to run any piece of program twice before he shouts out "hey, this is crap! it's way too slow!" ?
2nd) the algorithm i checked out was highly recursive. so isn't the appropriate function compiled the first time it is called and afterwards only the generated machine code beeing called? (the real code is really more than short, so the compile time [spread over some thousands function calls] should be really negligible ?)
|
|
|
|
|
l3st4rd wrote:
does any end-user take care to run any piece of program twice before he shouts out "hey, this is crap! it's way too slow!" ?
Most code gets executed many, many times in one use of a program. So, the cost is not that bad. But it IS a cost that needs to be considered. Or you can use NGen to run a precompiled executable and avoid this cost. However, the idea is that the .NET compiler can compile code optimised for your processor, etc.
l3st4rd wrote:
the algorithm i checked out was highly recursive. so isn't the appropriate function compiled the first time it is called and afterwards only the generated machine code beeing called?
Good point - in this case, it may not make much difference to the result. But it would still make some... (clutching at straws). I'm not here to defend C# at all costs, C++ is better at somethings, for sure. I'm a C++ MVP, for goodness sakes. I just want to make sure you are making a fair comparison.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hey, i got _NOTHING_ against c#. it's really nice for developing some tools / smaller apps. the developement time is (compared to VC 6.0) MUCH faster. i use c#.NET alot, but i think there're some situations where c# is just the wrong choice. but with the project i'm doing at the moment (it's my master thesis) i had _NO_ choice which language to use, so i try to make the best of it. and i feel sloppy delivering a kinda working program which every user would complain about. i used c++ (and mfc) for years so i'm also tending to c++ (never ever tried c++.Net...) but now i gotta write my prog using c# and i give a f*** which language is better, i just wanna write a good program; thats all!
(IMO c++ is better, but this doesnt care here, i don't wanna start a discussion about this, every language has its warranty....)
|
|
|
|
|
l3st4rd wrote:
i think there're some situations where c# is just the wrong choice.
Agreed - it's not a magic bullet.
l3st4rd wrote:
never ever tried c++.Net...)
LOL - did anyone ?
Christian Graus - Microsoft MVP - C++
|
|
|
|