threading, posting data, text file

  • Thread starter Thread starter Boki
  • Start date Start date
B

Boki

Hi All,

I need to let user type some text in a textbox, and user will click a
button to submit the material.

It is very straightforward if we implement it by single thread.

But the submitting costs a lot of time, especially there are some
network latency.

I can't let user wait until the submitting is complete. ( my every
posting costs about 35 seconds)

So, I have to queue the strings that were typed by user, I need:

1. URL string.
2. User comments. ( string, but include newline, is that workable ? )

If I use writeline, the user comment might more than one line.

and I hope I don't need to control many text files at the same time.

Please give me your ideas.
Thanks!
Best regards,
Boki.
 
Boki,

You could always create a structure/class that has one property that
stores the URL, and another that has a string property that has the other
lines (you can store new line characters in a string). Then, you just pass
that instance of the class to your method which is processed on another
thread.
 
Boki,

You could always create a structure/class that has one property that
stores the URL, and another that has a string property that has the other
lines (you can store new line characters in a string). Then, you just pass
that instance of the class to your method which is processed on another
thread.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I need to let user type some text in a textbox, and user will click a
button to submit the material.
It is very straightforward if we implement it by single thread.
But the submitting costs a lot of time, especially there are some
network latency.
I can't let user wait until the submitting is complete. ( my every
posting costs about 35 seconds)
So, I have to queue the strings that were typed by user, I need:
1. URL string.
2. User comments. ( string, but include newline, is that workable ? )
If I use writeline, the user comment might more than one line.
and I hope I don't need to control many text files at the same time.
Please give me your ideas.
Thanks!
Best regards,
Boki.

Hi Nicholas,

I think my problem is the posting thread, it can only process a data
once at the same time, because it will post to website, the website
only accept single posting.

So, I can't feed the data to thread too quickly.

My idea is, prepare a text file, treat it as a queue, thread A feed in
data ( first in first out ), thread B read data, so the data structure
becomes a ring buffer, right ?

It seems C# no pointer, so I need to prepare a int to point to array
number by ourself ?



Thanks!
Boki.
 
Hi Boki

Try to use a thread to communicate with the website. This thread works on a
class derived from the class Queue, as long as the queue is not empty, the
thread tries to send the postings. All the clients post theire data into
this queue and the thread is invoked.

Regards Roman


Boki said:
Boki,

You could always create a structure/class that has one property that
stores the URL, and another that has a string property that has the other
lines (you can store new line characters in a string). Then, you just
pass
that instance of the class to your method which is processed on another
thread.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I need to let user type some text in a textbox, and user will click a
button to submit the material.
It is very straightforward if we implement it by single thread.
But the submitting costs a lot of time, especially there are some
network latency.
I can't let user wait until the submitting is complete. ( my every
posting costs about 35 seconds)
So, I have to queue the strings that were typed by user, I need:
1. URL string.
2. User comments. ( string, but include newline, is that workable ? )
If I use writeline, the user comment might more than one line.
and I hope I don't need to control many text files at the same time.
Please give me your ideas.
Thanks!
Best regards,
Boki.

Hi Nicholas,

I think my problem is the posting thread, it can only process a data
once at the same time, because it will post to website, the website
only accept single posting.

So, I can't feed the data to thread too quickly.

My idea is, prepare a text file, treat it as a queue, thread A feed in
data ( first in first out ), thread B read data, so the data structure
becomes a ring buffer, right ?

It seems C# no pointer, so I need to prepare a int to point to array
number by ourself ?



Thanks!
Boki.
 
Hi Boki

Try to use a thread to communicate with the website. This thread works on a
class derived from the class Queue, as long as the queue is not empty, the
thread tries to send the postings. All the clients post theire data into
this queue and the thread is invoked.

Regards Roman

Boki said:
Boki,
You could always create a structure/class that has one property that
stores the URL, and another that has a string property that has the other
lines (you can store new line characters in a string). Then, you just
pass
that instance of the class to your method which is processed on another
thread.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi All,
I need to let user type some text in a textbox, and user will click a
button to submit the material.
It is very straightforward if we implement it by single thread.
But the submitting costs a lot of time, especially there are some
network latency.
I can't let user wait until the submitting is complete. ( my every
posting costs about 35 seconds)
So, I have to queue the strings that were typed by user, I need:
1. URL string.
2. User comments. ( string, but include newline, is that workable ? )
If I use writeline, the user comment might more than one line.
and I hope I don't need to control many text files at the same time.
Please give me your ideas.
Thanks!
Best regards,
Boki.
Hi Nicholas,
I think my problem is the posting thread, it can only process a data
once at the same time, because it will post to website, the website
only accept single posting.
So, I can't feed the data to thread too quickly.
My idea is, prepare a text file, treat it as a queue, thread A feed in
data ( first in first out ), thread B read data, so the data structure
becomes a ring buffer, right ?
It seems C# no pointer, so I need to prepare a int to point to array
number by ourself ?
Thanks!
Boki.

I think I know what you mean, thanks :)

Boki.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top