|
Zimbar wrote:
++? Or it only compiles to bytecode like Java?
That is sort of right. But yes, you need the runtime.
Zimbar wrote:
Do you think that C# is good for Graphics Applications? (I mean is it fast enough)
No. My graphics filters were benchmarked by Chris L. and the same code in C++ was 25 times the speed. I wrote mine in C# only because I needed to, to differentiate them from some I wrote in C++ for a former employer.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
25x?
That seems surprising. Care to share a bit of code (both in C++ and in C#)?
|
|
|
|
|
My C# code is here on the site - I did not think the speed was too bad ( but I maintain C# is the wrong tool, mostly because Microsoft in their wisdom have made pixel access 'unsafe' ), but Chris Losinger has posted the question based on conversion to C++ that he did.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Two questions:
1) Was the code written using GetPixel and SetPixel()?
2) What other option was there besides making pixel access unsafe? I don't like it either, but I can't see how you can be fast without being pointer-based.
|
|
|
|
|
Anonymous wrote:
Was the code written using GetPixel and SetPixel()?
Mine was not, that would not be unsafe. I assume Chris' was not either - he writes an imaging library, you know.
Anonymous wrote:
What other option was there besides making pixel access unsafe? I don't like it either, but I can't see how you can be fast without being pointer-based.
The obvious option is a function that returns the bitmap as a 2D array. How do you think every array in memory is laid out ? There is no reason to regard it as unsafe to access the member data of the Bitmap class.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Sorry that the last one came across as anonymous. Not sure why...
Christian Graus wrote:
The obvious option is a function that returns the bitmap as a 2D array. How do you think every array in memory is laid out ? There is no reason to regard it as unsafe to access the member data of the Bitmap class.
Hmm. Did the C++ version use pointer arithmetic, or did it use array indexing? I agree that you can return a 2D array, but I don't that would help much in this case because:
1) multidimensional access in C# is a bit slower than single dimensional
2) Array indexing is slower than pointer arithmetic
3) The .NET classes are a thin layer on top of the unmanaged GDI+ functions. If you can't change that, then you'd have to copy from the unmanaged world to the managed world and back, which would be really slow.
#3 is a design decision which I hope can be addressed in the future. I'm not sure what we'd do to address the others.
Thanks for the info; I'll take a look at the code.
|
|
|
|
|
Eric Gunnerson (msft) wrote:
Did the C++ version use pointer arithmetic, or did it use array indexing?
Pointers, for speed. I appreciate all that you are saying, my point is more that C# should be able to access the bitmap data in one call, instead of using get/setpixel which is notoriously slow, and without having to write code that will be marked 'unsafe'. Ideally, I guess that means GDI+ should provide another call, or C# should sandbox the GetData call and return the data. This will be slower, of course, but I would not mind that if I had the option to go unsafe, but could do pixel access in some way that was as optimised as I could hope for without marking my code as unsafe.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
I looked at the code, and it pretty much looks like my code.
Is there anyplace I can look at the equivalent C++ code that Chris timed?
|
|
|
|
|
If you installed vs.net, you can find C# language sepecification document on VC# folder, and also you can find many resource on msdn online.
I'm amumu, and you?
|
|
|
|
|
Hello All,
I have a component (say AManager) managing a set of custom controls (say AView) as standard collection on .NET form.
A property of the AManager (Views) displays the collection editor dialog with the "Add" and "Remove" buttons.
Now, the problem is, the "Add" button adds a new AView object to the collection and the necessary code is generated in the Form file. However, the code which will add the custom control to the form is not generated and therefore the control does not appear on the form. I had to manually update this part.
ie. the following line in the form source is not updated
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.customControl12,
this.customControl11});
when I use the collection editor to add customControl13 to the collection. So, I have to manually add the line as:
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.customControl13,
this.customControl12,
this.customControl11});
Any help? Am I missing some attributes?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
How do I iterate through a collection while modifying it?
Let's say I have a hashtable I want to clear one entry at a time. I might want to retrieve an object from the table and do something with it before I remove it.
I can not use the foreach statement on the dictionary entries in the table without getting an exception. I've understand that enumerators work the same way. The remove method is no good either since it does not return what it removes.
How can I solve this problem as easily as possible? Any hints would be much appreciated.
Thanks!
|
|
|
|
|
J. Ehrnström wrote:
I can not use the foreach statement on the dictionary entries in the table without getting an exception. I've understand that enumerators work the same way.
Actually that is the same thing Underneath it all foreach just uses enumerators to iterate through the collection.
What I would do is to get the collection of keys, then iterate through that; to remove what you need to.
Hashtable table = .....;
object [] keys = new object[table.Keys.Count];
table.Keys.CopyTo(keys, 0);
foreach(object key in keys)
{
object obj = table[key];
} HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thanks for your quick reply. I tried your solution and it worked just fine.
I actually did think about adding the keys to their own list using an ArrayList, but that list would only have referenced the original keys, so the problem would have remained. You solved that problem by explicitly copying the keys.
Thanks again!
|
|
|
|
|
You an encapsulate this in a class, which then allows you to write:
foreach (MyClass c in new IterIsolate(arr))
{
}
I did a column on this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp01212002.asp
|
|
|
|
|
Thanks for the tip. Your sample was right on target.
|
|
|
|
|
I am working on a C# wrapper for the XML Document schtuff. I am also writing a GUI that nicely formats my XML, etc. The idea is that I have a couple of edit boxes, a combo and a button. When you push the button, the parameters in the two edit boxes get passed to the function selected in the combo. I am wondering if by reflection, or any other means, I am able to call the method I want to, by having it's name as a string ? Currently I have a big old switch statement, but that seems far cooler and a chance to play with something that has no C++ equivelant I know of, assuming it does what I think it does.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
yes, you can do that just fine with reflection.
You just have to know the Type which the method belongs to.
call Type.InvokeMember on it, passing the method name, object instance, and args.
you can also get the Type from a string via Type.GetType.
|
|
|
|
|
So if I have a member object called m_XMLDoc, and it contains methods that are in my combobox, I can get the method selected as a string called sMethod, and do something like
m_XMLDoc.InvokeMember(sMethod, new Array(sArg1, sArg2));
???
I am sure the syntax is wrong, I'm just clarifying that I have the general idea right.
Thanks for helping.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
the idea is right, but yes, the syntax is wrong.
you call InvokeMember on the System.Type class, not the instance itself.
if you have the instance handy... you can do
m_XMLDoc.GetType().InvokeMember(sMethod, new Array(sArg1, sArg2));
but I believe that you'll need to pass the instance back in as an arg as well, because you call it from the Type not the instance.
|
|
|
|
|
Cool. Now that I know that it's worth looking, and what I am looking for, I am sure that 'Inside C#' will fill the gaps for me.
Thanks again.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
hello to all,
not to long ago, there was an article on this site about Load balancing in a Mult tier scenario using remoting.
http://www.codeproject.com/info/error404.asp?404;http://www.codeproject.com/useritems/Multitier.asp
this no longer exists. i'm curious if anyone out there either kept a copy of the code from this article or has a method in doing this.
i've got my ntier going (using Remoting) and would really like to balance the servers.
thanks,
Orion
|
|
|
|
|
I need to get to a certain posistion in a remote file [online], but i do not want to download all of the bytes that arenot after the point in the file i want to download from.
any help.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
I've downloaded Compuware's DevPartner "community" edition profiler. However, what I'm really looking for is a 3rd party dev utility that will trace my C# method calls as the app is exercised, trace the parameters passed to each method (list their values), print the trace, etc.
Does such a tool exist and where may I find it if it does exist?
Thanks very much.
|
|
|
|
|
I saw a small util called TraceHook somewhere here on CodeProject or somewhere else maybe. Mite be helpful.
READ MSDN
|
|
|
|
|
Thanks, leppie. I'll search for TraceHook.
|
|
|
|