multi threading

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

my program have as many as 8 threads running at a same time. can different
threads open a same file at the same time? let say thread1 open a file
abc.txt at the same time with thread 2, both doing at different operation...
 
How big is the file and what operations are you doing on it? The reason I
ask is, if it's a small file, would it make sense to read it all into memory
and work with it? Are all threads just reading? Or are some trying to
write to the file?

Thanks,
Michael C#
 
Hi,

the file is not very big, around 2kbytes, it is a .PRN file(printing). i am
send this file to 2 different printers using threads. The reason i am doing
this, is to find out whether threading allow me to print at different
printers at the same time. Do u have other alternatives?

Thanks
youyi
 
NotRegister,

There is no difference when you use 8 programs or 8 threads for reading the
same file.

All options as with the method that you use to read the file are the same.

I hope this helps?

Cor
 
thanks, may i ask if i got problem regarding printing in windows, which forum
should i go? i been trying to find a solution for my program for many days
but still no suitable answer.

For you information...
1) I am design a vb.net program
2)supposed to send a single file to 8 different printers to print at the
same time

I am have been using threads, to divide the task to the 8 printers. I have
tried using printdocument, printDialog, process, but the main point i want to
emphasize is that this program is to test printers that have not gone to the
market, i will prefer if i am able to send a print job to the printers
without installing any printer drivers in advance.

i read many article which allow user to send RAW data directly to printer,
what does it mean? does it mean i do not requred drivers? pls help me to
clariy..

Thanks
youyi
 
Youyi,

I have seen both parts of your question. In the multithreading part I see no
problems. In the printing without drives have I thought it seen that Ken
wrote to you that it is impossible.

Mostly when there comes than no other answer, than nobody active in this
newsgroups know an answer.

However your question is difficult. You can print over the network however
than you print to a spool or you can print to a parallel port (for mostly
old printers as well serial ports) however than you can only connect one
printer.

So I think at least you have to tell more where those simultanisly 8
printers are connected too.

Not that I than have direct an answer.

Cor
 
notregister said:
my program have as many as 8 threads running at a same time. can different
threads open a same file at the same time? let say thread1 open a file
abc.txt at the same time with thread 2, both doing at different
operation...

Yes, that should work, at least when you open the files for reading. But
what is the advantage of reading the same file more than one time at the
same time?
 
Hi,

The program i designed have 3 option, usb printer,network printer and
parallel port printers. As for parallel port printers, i have successful
print with 8 printers with a physical electronics print switch. that is
connected to an PC. If it was the case of usb printers,it will be connected
to a usb hub, and finally if it is through a network, they will be connected
to the main PC through LAN.

As for the usb connection and network printing, i have been trying many type
of techniques like threading and processstartinfo() to help me, but to no
valid...
i try using windows API, but most of them refer to VB6, and they mostly use
default printing, i do not think changing default printers in different
threads will work, or does it work? not too sure...

Thanks for all your advices, i appreciated all ur helps, pls let know also
if there any other suitable platform to ask this type of question, because
personally i feel this is 50% VB.net question and 50% windows question, it
might not be enough to solve this with vb.net knowledge alone...

regards
YouYi
 
Notregister,

What is the reason that when you can do it withouth multithreading, that you
cannot do it with multithreading.

When you can do it like this
do while notReady
subprint1
subprint2
subprint 3
etc
loop
sub print1
do while not Ready
print row
end sub

You can do it as well like this (in the most simple format)
MyThread1 = New System.Threading.Thread(AddressOf me.print1)
MyThread2 = New System.Threading.Thread(AddressOf me.print2)
MyThread3 = New System.Threading.Thread(AddressOf me.print3)
etc until 8

MyThread1.start
MyThread2.start
MyThread3.start
etc. until 8
sub print1
print the complete file
end sub
etc.until 8

Cor
 
Hi Cor,

for parallel prot ,i can do it without multi threading, because most of the
broadcast printing is handle by a parallel ports electronic switch. As for
the other 2 option, i tried using multi threading. in fact i was using ur
second option in my program, the trouble is the selection of printername for
each thread, though 8 similar printer are connected to the same PC, but they
do have different printername and i wand different threads to point at
different printer...

for each thread i tried to stated a different printer name,

Dim prSet As New Printersettings
prSet.Printername = "Epson Inkjet 2"

but somehow whenever i tried to print,it fail to print to each respective
printers, only default printer

regards
youyi
 
Youyi,

I have seen both parts of your question. In the multithreading part I see no
problems. In the printing without drives have I thought it seen that Ken
wrote to you that it is impossible.

Mostly when there comes than no other answer, than nobody active in this
newsgroups know an answer.

However your question is difficult. You can print over the network however
than you print to a spool or you can print to a parallel port (for mostly
old printers as well serial ports) however than you can only connect one
printer.

So I think at least you have to tell more where those simultanisly 8
printers are connected too.

Not that I than have direct an answer.

Cor
 
If you're just reading in the file, and it's not too darn big, I would just
read the whole thing in one time and print it from memory using multiple
threads or a single thread, or whatever method you wish. I was concerned
you might be attempting to read and write to the same file simultaneously
using multiple threads, which would obviously cause problems...
 
Thanks for ur reply, that would really solve half of my question, now i left
with the printer problem...like i wrote in my other post, i would like each
of my threads to print this same document to a different printers, bypassing
the driver if possible, which mean sending a printer-ready data directly to
the printers it self, the trouble is, setting printername within each
threads...i really do not know whether windows and vb.net can really allow
broadcast printing? is there any example on broadcast printing? thanks

regards
youyi
 
Sorry I'm not familiar with printing by bypassing the printer drivers... At
least not since WFW 3.11 LOL...

Thanks
 

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

Similar Threads


Back
Top