|
I don't know! What exactly do you want? What's wrong with a message queue?
There are async methods (with callbacks) for sockets, is that what you're looking for?
Do you want to start a new thread from the delegate? (could give trouble)
|
|
|
|
|
I am using AsyncCallback, but if the number of message increse the messege queue will go long and the replay get slow.
i want make it fast.
Will the AsyncCallback can handle any number of clients at a time with out delay??
I am trying to use multi thread in delegate for handling messages.
Will it work?
Thankyou
YPKI
|
|
|
|
|
It depends. It's possible to make it work without being delayed by other messages (of course you can not make it take zero time), up to a certain limit of course. The messages you send over the internet will never go in parallel, but the processing of them can. If your callback immediately starts a new async operation and only Then processes the message, that should be OK (I think.. test first)
|
|
|
|
|
Hi,
AFAIK all async callbacks (such as supported by Dns.BeginGetHostEntry) and other async operations (such as SerialPort.DataReceived event) execute on the ThreadPool, which holds a collection of Threads (25 or more) ready to execute your code. You can't (or shouldn't?) modify the behavior of those threads (priority, IsBackground, ...)
If you don't like/trust the ThreadPool, don't use async callback, just create your own threads and let them to whatever it is you need in a synchronous way.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
so you mean async callbacks have its own thread pool(its already work when we use async callbacks...ryt ??? ).. no need to create our own thread
So better, not to create thread for speeding up message queue process..
Thankyou
YPKI
|
|
|
|
|
Not sure you got my drift. AFAIK all callbacks use the existing ThreadPool (which gets created very early in the startup of a .NET app). And using your own threads, so you can control them any way you like, only requires you to create threads once, say one Thread each time you open a SerialPort.
FWIW some info on ThreadPool: http://www.ddj.com/hpc-high-performance-computing/216500409[^]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Dear sir,
i am Nidish, traineee .NET developer for Forthought pvt Ltd, Bangalore, India. I would like to to know the method to Programmatically send email using outlook Express 6.0. I have the code to access Microsoft outlook but failed to find method to access outlook express 6.0. please be free to send reply to my Email id : nidi2999@gmail.com
|
|
|
|
|
hi, Nidi i'm also searching same thing
|
|
|
|
|
Not very hard it would seem clickety[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I love circular references. I followed the link, then clicked on the first item returned. It was this question.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Oops - it never occurred to me to follow it any deeper, I'm glad there were a few more than just this one.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
one more reason to google before asking here.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I am doing geocoding using Google Map API but the problem is,
if i pass Lat (25.093369) and Lon (121.5669693) points of Taiwan to Google Map API then it gives me address in following way,
西安里 Neihu District Taipei City Taiwan 114
but i need the whole address in Chinese Language
Can anyone help me?
thanks in advance
|
|
|
|
|
Yeah, Google. They wrote the API and they support it. I suggest dropping them an email or looking for the support forum for it.
|
|
|
|
|
Lets say you have to do 4 things,
void f1()
void f2()
void f3()
void f4()
Alt 1: Run them like this
f1(); f2(); f3(); f4();
Alt 2: Run them each one with a separate thread
Thread t1 = new Thread (f1); t1.Start();
Thread t2 = new Thread (f2); t2.Start();
Thread t3 = new Thread (f3); t3.Start();
Thread t4 = new Thread (f4); t4.Start();
(the functions just read resources, they dont write, so dont worry about threading sync)
Alt 2 should take less time than Alt 1???
I tried to test this but I'm doubting of the results because at the beginning I had one result (threading is faster) and then anoter (same times)
Logically thinking.. the threading solution shouldnt be faster because in reality they arent running at the same time.. they are being switched ( thats why there is only 1 CurrentThread when one calls Thread.CurrentThread static method )
Please help.
|
|
|
|
|
Hi!
This highly depends on what your f1-f4 are doing.
When each one can run through all the time, without having to wait for anything, I'd guess the 2 solutions run equally fast (at least on a 1 processor system and neglecting the overhead of thread creation).
But as soon as one of them has to wait for a result (network, file, ...), the scheduler can assign the waiting thread's time slice to another thread, making the whole program running faster.
Hope this helps...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Adding to mav's response, if you have a multi-core processor, the multi-threading solution may run faster.
But my advice is don't use threads unless there's a convincing reason to do so. They can introduce all sorts of subtle, difficult-to-debug problems.
|
|
|
|
|
That depends on what each of these methods is doing. Creating and starting a new thread is an expensive operation, so if it doesn't take very long to execute the method, just starting one thread can take longer than executing the 4 methods sequentially.
|
|
|
|
|
Hi,
if two or more of the jobs (f1...f4) have an execution time that is (or may be, depending on circumstances) noticeable for the user (i.e. more than 30msec), put them in separate threads/ThreadPool/BackgroundWorker so they can
1) execute in parallel (when your system has hyperthreading, or multiple cores, or multiple processors)
2) self-organize their execution (i.e. when one has to wait some other can continue)
OTOH if you do it all sequentially and your Task Manager shows the CPU is fully loaded (which means there are no waits and the number of cores does not exceed the number of running threads) then you won't gain anything by adding threads.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Well, this question was due to a question I had on a test:
It said something like:
"Some people are not happy with their statistics software because of the performance.. What would you do to try making it better"
And the code is like
"...
info = SomeClass.Load ( file )
Analyzer.AgeAnalysis( info )
Analyzer.SexAnalysis( info )
Analyzer.RaceAnalysis( info )
..."
1. Can't have access to the package that contains Analyzer and SomeClass
2. Therefore can't know what those methods do (but it says explicitly that they can run in different orders so there is no "wen one has to wait some other can continue")
And the solution was to make them run in different threads ..but i'm doubting that would improve the performance...
If there isnt dual core, hyperthreading, etc. in the system, and there isn't need to self organize.. then why would them run faster? If
f1 does f1.1, f1.2, f1.3
and f2 does f2.1, f2.2, f2.3
Without threads they would run like
f1.1
f1.2
f1.3
f2.1
f2.2
f2.3
And with threads, they just would run mixed, for example:
f1.1
f2.1
f1.2
f2.2
f2.3
f1.3
And that isnt running faster.. just in different order
Do you think ambiguous the question?
|
|
|
|
|
Yes, you are right to doubt the correctness of the answer given the simple but theoretical question.
if there is only a single core and there are no waits (which means no input/output, no disk accesses, and almost no user interface; not an average day-to-day situation) then threading won't help. In fact, without threading it will behave better because:
1) you don't have any threading overhead (order of milliseconds), so overall execution time would be slightly less
2) you get partial results sooner (whereas the interleaved execution will take longer to come up with something since it isn't focusing on a single part of the overall job)
There is one more aspect to the matter: "locality of reference"
Assume a lot of data needs to be handled, RAM memory being slow, and caches (level1 and leven2) being limited in size; then it is very favorable to perform all computations on a subset of the data (not exceeding level2 cache size), then move on to the next load of data, etc. One can hope to get this for free with multi-threading, but that only works well if all the jobs happen to proceed at the same pace (i.e. require the same number of instructions per amount of data). One would better organize for this, with multi-threading plus interthread synchronization, or, much simpler, a single thread and a loop that makes it happen.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hello,
I am having a very strange problem.
I created an application in Visual Studio C# 2008 using .net 3.5 SP1.
The application looks perfect in Windows XP, but in Windows Vista, the buttons are a lot larger and don't fit their space.
Here is an exaple :
http://www.sodevrom.net/xp.jpg
http://www.sodevrom.net/vista.jpg
As you can see, in Windows Vista the buttons are very large.
What can be the cause of this ?
Thank you in advance
|
|
|
|
|
It's not just the buttons, but the text overall. Maybe changing the settings in Control Panel could fix it. Not sure, but just an idea
|
|
|
|
|
It is because different version of window that you are using. Different versions of Windows have different UI and Theme settings. So the form ui also changes accordingly.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
Hi,
Thank you for your reply but it does not help to much.
I don't understand how can the Font size change when I specified an EXACT font from c# : Microsoft Sans Serif, 8.25pt
Any other ideeas ?
Thank you
|
|
|
|