Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

multithreading

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
request - 16 Mar 2005 14:37 GMT
Hi
I have written a program which receives mails from server using POP3.
it's downloading sequentially. now i want to use the multithreading
in this regard where i can create threads for each and every
mail...and download those mails simaltaneously.
if u have any idea please help me out.
Regards
request
Severian - 16 Mar 2005 18:26 GMT
>Hi
>I have written a program which receives mails from server using POP3.
>it's downloading sequentially. now i want to use the multithreading
>in this regard where i can create threads for each and every
>mail...and download those mails simaltaneously.
>if u have any idea please help me out.

First, be careful to to share resources without synchronization: two
threads shouldn't write to the same file simultaneously, for example.
Mutexes, critical sections and semaphores can be useful for this,
depending on the circumstances.

I would look around on SourceForge, CodeProject, and CodeGuru for
projects that do similar things -- perhaps as servers -- and learn
about synchronization between threads.

Since your application is a client, it can start a thread for each
POP3 server. If the e-mails are being written to separate files, you
only need to coordinate file names between the threads; if appended to
a single mailbox thread, then the threads will have to wait for each
other to finish writing a message before beginning to write their own.

Another option would be for each receiver thread to write each message
to a temp file. An additional thread would be signaled when a file is
complete and append it to the inbox.

I hope this helps and gives you some ideas.

--
Sev
Severian - 16 Mar 2005 19:36 GMT
I have corrected several typos in my response below. Then I must go do
some real work until my brain starts working properly again!

>>Hi
>>I have written a program which receives mails from server using POP3.
>>it's downloading sequentially. now i want to use the multithreading
>>in this regard where i can create threads for each and every
>>mail...and download those mails simaltaneously.
>>if u have any idea please help me out.

(I am assuming you are downloading from multiple servers
simultaneously, and not trying to download a bunch of messages from a
single account; I don't believe POP3 even supports the latter)

First, be careful *not* to share resources without synchronization:
two threads shouldn't write to the same file simultaneously, for
example. Mutexes, critical sections and semaphores can be useful for
this, depending on the circumstances.

I would look around on SourceForge, CodeProject, and CodeGuru for
projects that do similar things -- perhaps as servers -- and learn
about synchronization between threads.

Since your application is a client, it can start a thread for each
POP3 server. If the e-mails are being written to separate files, you
only need to coordinate file names between the threads; if appended to
a single mailbox *file*, then the threads will have to wait for each
other to finish writing a message before beginning to write their own.

Another option would be for each receiver thread to write each message
to a temp file. An additional thread would be signaled when a file is
complete and append it to the inbox.

I hope this helps and gives you some ideas.

--
Sev
Ioannis Vranos - 16 Mar 2005 18:32 GMT
> Hi
> I have written a program which receives mails from server using POP3.
> it's downloading sequentially. now i want to use the multithreading
> in this regard where i can create threads for each and every
> mail...and download those mails simaltaneously.
> if u have any idea please help me out.

Idea about what? At first, opening a connection for each email
separately doesn't sound good, first because it would increase the load
on server, and second because it may look like a password attack and I
do not know if all servers will allow many connections from the same
address (mine wouldn't). :-)
Severian - 16 Mar 2005 19:34 GMT
>> Hi
>> I have written a program which receives mails from server using POP3.
[quoted text clipped - 8 lines]
>do not know if all servers will allow many connections from the same
>address (mine wouldn't). :-)

I assumed he meant different POP3 servers or at least accounts (I use
3 servers and 5 accounts). I don't think the POP3 protocol even allows
multiple connections to the same account.

--
Sev

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.