|
Accessing the system spool needs admin permission, so i am already on that way ... not happy with it but we are on a Windows system not on Linux ... so everything needs admin ...
... and ... everything should be in a service, now i realized that printing from a service is *$&*# ... sorry ... but is there a other way ... in some forums they use PDF to print to and then combine the PDF and print it ... some SDKs are available, so there must be a way doing it ... i am not the one who gives up early ... but time is running away
|
|
|
|
|
I give up accessing the spool ... dave is right ... its a waste of time ...
Now i use pdfsharp.com[^]
Printing on a PDF Printer >> Combine the PDF >> Print the combined PDF on the HP9000 ... should be easy ?!
Hope this works out for me ... unfortunately i must use Acrobat Reader for printing ... but therefor it is free !
|
|
|
|
|
tolarion wrote: Printing on a PDF Printer >> Combine the PDF >> Print the combined
PDF on the HP9000 ... should be easy ?!
Doesn't that have the same problem as a docx file?
Open a command prompt and type COPY WordDoc1.docx + WordDoc2.docx WordDoc.docx, then try and open the WordDoc.docs file.
There's no "easy" way to achieve what you're trying. If it needs be done from several clients, then your best option would be to write your own device-driver. That would be done in an unmanaged language, not in .NET.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Cool 
|
|
|
|
|
I'm designing an application which consist of multiple clients that connect to a server using sockets. I'm trying to figure out a way to monitor the connection and if no data is transferred within a certain time from (say 1 minute) then the connection is closed (basically I'm trying to create a watchdog timer).
From what I've been reading it seems that I would need to use the AutoResetEvent class. The way I envisioned it working is that every time the server receives data from a client it resets the timer of the AutoResetEvent.WaitOne. What I've come up with so far is something like this in the server application:
Dim autoEvent as New AutoResetEvent(False)
If autoEvent.WaitOne(1000) Then
autoEvent.Reset
Else
Close connection and inform user
End If
When the socket receives data it will call autoEvent.Set which will cause the autoEvent.Reset method to be called. This would obviously be started on a new thread so it wouldn't block the main thread handling the data.
Is this correct or is there a better way to do this? Any links to creating a watchdog timer would be appreciated also. Thanks in advance for any help with this.
|
|
|
|
|
That seems like the best way to do it to me. BTW, your timeout is set to 1 second, not 1 minute. That could be for testing purposes. Just sayin'...
|
|
|
|
|
The timeout I just wrote that for the purposes of the post. When the autoEvent.Reset is called (as a result of autoEvent.Set being called), will the code in essence jump back to the autoEvent.WaitOne or will the code jump to after the If...Then...Else block?
|
|
|
|
|
|
Hi guys this is simple but I'm a novice trying to cache the getMyresult function but I'm struggling to find the code to do so, could you help please? . I don't want the answer just some of the methods and syntax.
Sub Main
console.writeline(getmyresult(2))
console.writeline(getmyresult(3))
console.writeline(getmyresult(2))
console.writeline(getMyresult(3))
End Sub
function getMyresult(X as interger) as integer
dim Y as integer=LongCompute(X)
return Y
end function
function LongCompute(X as integer) as integer
system.threading.thread.sleep(1000)
return x^2
end function
modified 20-Jun-13 14:00pm.
|
|
|
|
|
GetMyResult has to maintain it's own cache of result values. Create a collection to store Key/Value pairs, usually a Dictionary(Of Integer, Integer). The Key value will be the integer you pass in and the result will be the value returned by LongCompute.
Basically, when GetMyResult is called, it uses the value passed in to search the Dictionary for that value. If it's found, it can return the value associated with that key. If it's not found, then you call LongCompute with the passed in value, get the result, and add the new key/value pair to the dictionary. Lastly, return the result back to the caller.
|
|
|
|
|
Just curious Dave and Poster, but what does this mean in context - "cache"? I guess the simplicity of the code has me puzzled - two-stepping for a single computation. I can't see beyond that. I use a dictionary and actually truly cache with the class. Purpose?
|
|
|
|
|
To hold a table of values that have already been computed so you don't have to run through a potentially time-consuming calculation again to return the same value for the given input.
|
|
|
|
|
Exactly the same way that I do on the accounting side of my apps, but I exlicitly set out to cache. Sorry to inject! I had curiosity get the best of me as I was looking at the code and realizing that it is a textbook example has answered the question. Once again, sorry! Thanks for the replies, and let me know if you solve the threading problem. LOL ... Attempted multitasking this day. 
modified 27-Jun-13 20:11pm.
|
|
|
|
|
Threading problem?? What threading problem??
|
|
|
|
|
|
Because his code is an example!
|
|
|
|
|
Dear Dave,
Many thanks for explaining it to me as well instead of just giving me the code,
My teacher will be impressed haha
Many Thanks
101
|
|
|
|
|
Prissy,
Thank you very much for the code I appreaciate the help im glad Dave explained it to me as this would of been cheating :P 
|
|
|
|
|
I don't do it any other way! Good Luck!
|
|
|
|
|
Is it VB 6 or VB .NET? I don't know about return statement in VB 6? I'm forgot to choose Question. Oh, it's a VB .NET Discussion. I don't know. Sorry.
|
|
|
|
|
|
I use System.threading.timer() to read RS232 data periodically,
But I found it seems the threading.timer() produces many threads,like each cycle it use a new thread to read.
Is the threading.timer use many threads of threadpool?
|
|
|
|
|
How are you using it? Creating it once then just handling the event, or some other method? Can you post the code where you instantiate it and where you handle it?
|
|
|
|
|
econy wrote: But I found it seems the threading.timer() produces many threads,like each cycle
it use a new thread to read.
From the documentation:System.Threading.Timer is a simple, lightweight timer that uses callback methods and is served by thread pool threads. It is not recommended for use with Windows Forms, because its callbacks do not occur on the user interface thread.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|