Waking a Windows (Spooler) printer - c#

I have a .NET 3.5 / C# application running on XP which receives data from another application in small batches (3 or 4 lines at a time), collects the data into a single print job, and eventually submits it to the Windows spooler. This data collection phase usually takes 20 - 30 seconds.
When watching the system in operation, I noticed that the printer that's being used (a networked laser printer) takes a long time - a couple of minutes - to warm up, and obviously this warm-up phase starts only after I've sent the complete print command to the spooler.
So, this got me thinking - is there a generic "fire and forget" method I can use to tell the printer to start its warm-up sequence? If so, I could trigger that immediately upon receiving the first chunk of data, and the printer can be warming up while I'm doing my data collection.
It's not the end of the world if this isn't possible, by any means, but it looks like a nice easy speedup!

Related

Sony RemoteAPI delays after starting Liveview

Good worktime!
I'm writing C# warp around Sony Remote API, using Android test app as an example.
There became a problem with Liveview.
I start liveview streaming by the API method "startLiveview". Liveview data consumer works in a separate thread and it simply passes through frames if there's no time to draw them all (just like in the test app, as far as i understand).
However, after the startLiveview method is processed and fetching stream is started, the camera experience some difficulties with all other API commands processing in time.
E.g., after my warp discovers the camera and connects to it, performs startRecMode and so on, it can take pictures very fast. However, since liveview is started, the camera can't process all actTakePicture calls in time. There can be seconds or even dozens of seconds i have to wait before the shutter clicks.
I've tried to stop liveview before starting picture taking. It doesn't matter - stopLiveview command experiences the same problem, it takes even minutes to process it (there are minutes to return from System.Net.WebClient.UploadString).
I've tried to use startLiveviewWithSize instead of startLiveview and to pass the smallest size available (there is "M" with Sony A7R i'm using). No result.
What can i do to successfully stop the liveview or, as a max wish, to get rid of performance penalties when the liveview is on?
Thank you in advance!
p.S. Using MS VS 2010, .NET Framework 3.5, Sony ILCE Alpha 7R camera, all preprocessing settings found are switched off.

How to handle an infinite background task?

I want to develop an app which downloads small files continuously when my app is not in the foreground and sends a notification if certain conditions are met.
Problem is that periodic agents have a scheduled interval of 30 minutes and a duration of 10 seconds, while resource-intensive agents have a duration of 10 minutes and need an external power source.
How could I do to achieve my goal ?
If you don't mind upgrading your Application to WP8.1 then you can use a very simple class to download a file in the background.
BackgroundDownloader class. There is really good example at the bottom of the page as well.
Useful Links if you want to understand more:
Transferring data in the background Describes the events of the BackgroundDownloader.
Periodic Tasks should really only do something very simple IMHO (that is why they have those restriction, not download something continuously) for example, Grab the latest news from a feed and update the Secondary Title.

Windows 8 Phone periodic task not running

I went through the following documentation to create a background periodic task:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202941(v=vs.105).aspx
For some reason, I never see it running. (In the sense, the OnInvoke() method in the class SchedulerTaskAgent.cs never got invoked)
With debugger on, I was able to invoke the method using:
if(DEBUG_AGENT)
ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(60));
#endif
It ran fine every 60 seconds. I saw the debug statements I added to OnInvoke() getting printed every minute (60 seconds).
Then I commented out the above lines to test to see if OnInvoke() gets called by the OS at times (say like every 30 minutes or so).
It was never called. I connected the phone to my Windows computer and the phone was fully charged, but was not connected to Wifi, but to the cellular network.
I am not sure as to understand why it was not triggered. I attempted the whole day yesterday (at least 6 to 8 times waiting between 30 minutes and an hour).
How do I test periodic task in the real world scenario where I can't use: ScheduledActionService.LaunchForTest(...)
My phone was simply idling and the phone I use is exclusive for testing (I don't have any apps running in the background,the cellular network signal was really good, with battery up to 100%).
Also the periodic task is just going to print some messages and not going to do any network or resource-intense activity.
Thanks for your time.
Try adding a pound sign in front of the if.
eg.
#if(DEBUG_AGENT)
ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(60));
#endif

Is it possible to update more than 60 times per second with the XNA 4.0 Game class?

I'm having a problem with timing in XNA 4.0, writing in C# and using Visual Studio 2010 express.
I'm not writing a game exactly, but I'm trying to use XNA for it's simplified content pipeline, drawing, and timing. What I'm trying to do is write a program that can time a user's response to onscreen stimuli at very fine resolutions - less than 5 ms, ideally.
To do this, I need to call the update routine (so I can poll the keyboard) no less than once every 5 ms. Even in variable step timing, I can't get the timing below about 16 ms per call. This doesn't appear to have anything to do with the amount of processing that I do in my update and draw routines. I can comment out everything in both routines and the program still spends roughly 16.66 ms on each iteration.
In fixed step timing, I can set the target to about 60 iterations per second (16.66 ms between updates), but if I try to go any faster than that, the IsRunningSlowly flag is tripped, and the game seems to try to compensate - several iterations will run faster than 60 iterations per second, and then 1 iteration will run slower.
So I guess my question is this: is the 60 iterations per second the upper limit for XNA? Is it possible to circumvent it? Should I just ditch XNA altogether?
I really appreciate your time and knowledge. Thanks in advance.
The problem you are having is due to VSync. Disable it in XNA by adding this line to your game's constructor (assuming you have the default GraphicsDeviceManager graphics):
graphics.SynchronizeWithVerticalRetrace = false;
This will allow your game to run "fast as possible". This should be "good enough" for your purposes.
See this blog post for a description of timing in XNA.
If you wanted to get more fancy: For XNA on Windows I would consider using the Windows event loop and a high resolution timer directly. Note that Game in XNA (on Windows and Xbox 360) is entirely optional.
You'd want to move as many slow operations (eg: update and draw) and blocking operations (eg: vsync) off the main thread. Note that input in XNA can only be handled on the main thread. I think you can create the graphics device on a separate thread - although I have never tried it.
You should note that, if you are measuring reaction times, there is lag in between sending a "present" command to the GPU, and that content actually appearing on screen.
I'm not expert to XNA development, but, I know I have already similar "problem" in windows phone. (slowly problem).
When you have a lot of treatment, use multithreading programming,,
msdn : "Applications that use multithreading are more responsive to user input because the user interface stays active as processor-intensive tasks execute on separate threads. Multithreading is also useful when you create scalable applications, because you can add threads as the workload increases. "
Hope I help you...

WinRT timeout during a webrequest to detect slow internet connections

Is there a sample code available online to get WinRT to determine if its a slow internet connection within the first second of a web-request call so that I can cancel the request and switch to a local file at the start of the program. Metro requirements expect the app to boot up under 5 seconds and I need my web-request (of 300kb) to return well before that. its usually fast on WiFi but 3G speed may vary.
You can see if you are running on a 3G or WiFi connection by using the connectioncost api.
When you are on 3G you could consider using the local file anyway and then attempt to update it on the background. Additionally you might increase your logic further by checking if the user is currently roaming or even if he or she is approaching his or her datalimit, all which might influence your decision on where to load from. All this can be done through the same API.
You are also mixing up things a little as far as the 5 seconds for your app to start go. Your app can actually take 15 seconds give or take to provide something and only 5 seconds to suspend before you are forcibly cut off. If the 15 seconds isn't enough to start with you can also replace the default splash screen .. with your own splash screen and continue loading as long as you like. Keep in mind your user might not like it.
Why not load the local file and then try to update it on the background? I am not sure about your use case.

Categories

Resources