|
How to add image besides each item in ComboBox?
And how to load 2 columns from a table (id and name for example) as one item in ComboBox? (id will not show,Name shows there, but after select, pass id as parameter)
Thanks.
|
|
|
|
|
Hi,
I've seen a few Server/Client programs here. Many of the server programs that can handle many connections at the same use asynchronous calls. I just can't figure out why this approach is popular in C#. Why most people use it instead of threads? Any advantages? If I want to write a ftp server that
can take control of each connection(e.g. D/L speed control, kill connection on user's demand), are asynchronous calls recommended in this case?
Is the underlying mechanism of asychronous calls also use threading things?
Thanks in advance
A beginner
|
|
|
|
|
When there are too many connections, there are too many threads and if each connection requires moderate to heavy processing, you'll bring the machine down in no time
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
The "NT family" of Windows (ie NT, Win2K, WinXP) supports a feature known as "I/O completion ports". In this feature, the O/S calls back to the user code when an I/O operation completes. In .NET, the built-in async functions use this support.
That means you can be waiting for 100 different read operations to finish using completion ports without a lot of overhead, where if you used threads, you'd need to have 100 of them running at the same time, and that takes a lot more resources.
|
|
|
|
|
Eric Gunnerson (msft) wrote:
In .NET, the built-in async functions use this support.
Wow! That's cool info Eric Gunnerson. Thanks for that. It amazes me also to see you spot just the right threads here on CP.
Thanks, once again,
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
|
Thank you
but when to use threads? I mean what situations are better for creating threads, or in what cases, using asynchronous calls would be better? Now, I see that creating threads is more costly than using asynchronous calls. It seems that I cannot control the number of "threads" using asynchronous call. Then, if I'm writing a ftp server that only take 5 connections in maximum, it looks useless to me, is it?
|
|
|
|
|
One reason to use async over threads would be in the case of file transfers. You would need to have the thread spinning and polling for completion. With an async call you would be notified when the operation completed. I would say a thread would be better used for a things like background operations, like refreshing a directory listing. It can be launched while the use is doing something else without interfering.
|
|
|
|
|
If there's built-in support using completion ports (ie there are BeginXXX() and EndXXX() calls on the class), I think that's always the preferred choice, since it doesn't take any threads at all.
It is true that for small numbers of concurrent processes, it can be a lot easier to write them as separate threads, because you can write the code all at once as part of a method, while with the async case, you may have to write your code in several chunks as part of the callback routines.
|
|
|
|
|
If there's built-in support for async (ie the class has BeginXXX() and EndXXX() methods), then you would normally use that if you care about scaling.
If you're writing something small, then writing the threaded version is generally easier, because you write your code in one chunk rather than having to write several callback functions.
|
|
|
|
|
Eric Gunnerson (msft) wrote:
The "NT family" of Windows (ie NT, Win2K, WinXP) supports a feature known as "I/O completion ports". In this feature, the O/S calls back to the user code when an I/O operation completes. In .NET, the built-in async functions use this support.
What happens on 98/ME (*shudder*)?
James
Simplicity Rules!
|
|
|
|
|
On the 98 series, the runtime emulates the feature using threads.
|
|
|
|
|
Thanks Eric
James
Simplicity Rules!
|
|
|
|
|
I want to control the version of an assembly.In the textbook,it write [assembly:AssemblyVersion("1.0.0.0")] before the class ,i put it before the first class into the namespace,when i compile,it told me that 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'.
who does know how to define the version attribute?
thanks!
confused:
|
|
|
|
|
Assembly attributes need to be placed outside any namespace declaration.
HTH,
James
Simplicity Rules!
|
|
|
|
|
But when I put the attribute of [assembly:AssemblyVersion("1.0.0.1")] outside the namespace declaration,it emits the error that duplicate AssemblyVersion.
I can implement the version declaration in the file of assemblyinfo.cs。
oh,I catch that。The file of assemblyInfo.cs is one of the sourcecode,but it is made by the IDE。
Thanks very much!
|
|
|
|
|
Hello,
I want to write a programm which includes a
Listview, that should work like the view in the explorer.
The problem is that i can not move the items (shown as LargeIcons) in the listview.
Every Item should be able to be placed everywhere within the Listview.
(e.g. it should be possible that one Icons is over an other Icon)
I also want do drag and drop Listviewitems between to ListViews,
i created a new DataObject wich includs the ListViewItem and send it with the DoDragDrop function.
But if i drop the item on the other ListView, i first have to clone the Item and then delete the one in the origin ListView.
Is there any simpler method to realise that ?
Thanks in advance
Robert
P.S.: I use VB.Net but i think it would't be so difficult to import a conlusion from C#.
|
|
|
|
|
Do we have a popup menu like we have in VB6? This would be nice if we don't.
Nick Parker
|
|
|
|
|
Nick Parker wrote:
This would be nice if we don't.
Why do you say that? What's wrong with popup menus?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Nish - Native CPian wrote:
Why do you say that? What's wrong with popup menus?
Sorry Nish, I think I said that the wrong way, long day today.
I meant, if we don't have them, this would be a nice idea to implement. Are you aware of how to implement these in C# or VB.NET? I'll try to be more clear next time.
Nick Parker
|
|
|
|
|
Check out the ContextMenu class, you should find it in the Toolbox as well, toward the bottom.
James
Simplicity Rules!
|
|
|
|
|
Hey people...
I'm trying to use the UnhandledExceptionEventHandler to make a log of unhandled exceptions and fix them...
the problem is... when an unhandled error occurs the framework shows a debug dialog before running my custom UnhandledExceptionEventHandler, even in Release mode.
How can i avoid this dialog?
tnx
Vanclei Matheus
Brazil
MSN Msgr - vmatheus@msn.com
|
|
|
|
|
I wish we had a C#/.NET FAQ here at CodeProject. This link provides an answer you need.
New Window
|
|
|
|
|
Rama Krishna wrote:
wish we had a C#/.NET FAQ here at CodeProject.
You could always start one The thought had crossed my mind a couple of times; but I hadn't seen too many questions asked often; except for "Can I create a program in C# that doesn't require the .NET runtime?".
James
Simplicity Rules!
|
|
|
|
|
This sounds like a really, really, really good idea. I think I will compile a list of FAQ's that I have seen and try to put something together. That is unless someone else is already working on this, I would like to contribute though.
Nick Parker
|
|
|
|