I am developing a WPF application when the application is shown a thread work
and show a refreshed data on the application ui .
for saving performances i want to stop this Thread if the application is 100% covered by another application .
for example if the user is using another application that take the right half of the screen ,and my app is shown on the left half of the screen , the app must steel works cause the user is using the other app and watching the
changed data on my app .
if the application is back grounded or 100% covered by another app window or
minimized must stops;
i tried many solution like using the Deactivation event of the window
and p invoke but that not resolve the situation.
and thanks you.
Related
I created app that open every time that I start pc. So its so annoying to close it every time so I'm wondering if its some code that will hide my console app. I saw videos and tutorials on forms but idk how to do it with console app.
The easiest way to do this is change your console app to a windows app.
Console apps get a console made for them by Windows. But if you change it to a windows forms app, then windows expect the application to make a window, so if you never make a window, then it will never show
The other way is to turn your application into a service. This has some additional requirements in terms of programming
Option 1
You can use this run command:
start /min "SomeTitle" MyConsoleApp.exe myarg1 myarg2
Thus it will be on the taskbar minimized.
Option 2
If you use a file link in the start menu, select the start minimized option for the exe.
Option 3
Using a WinForm app you will be able to use a tray icon by setting the main form as not visible, to say it simply because it can be complex according to the expected behavior, and it will not be in the taskbar too.
Option 4
If you don't want a main form, create a win form app, delete the form file and the code in the main method, and you're done, without GUI nor console, no main input and no main output but you can show MessageBox and some forms when necessary, just a background process only visible in the Task Manager.
With that you can add a tray icon to to offer exit and some status information for example.
Option 5
Also you can create a windows service:
.NET console application as Windows service
Note
In all cases, if you don't use an internal message events dispatcher like the WinForms Application pattern or WPF and so on, be carefull to not saturate the CPU with the processings like with loops and use Thread.Sleep() between iterations or any thread idleing pattern or some timer if necessary.
I am working on a program that starts several other c# WPF applications and checks wether there are errors (using .NET Automation Services / UITesting).
One of the requirements of it is to take a screenshot of the main window and to put it into a word document. I alread got it working quite fine when it´s one application at a time (using code from this site: http://www.developerfusion.com/code/4630/capture-a-screen-shot/) , but as soon as i am using parallelism (say, checking 5 applications in a parallel manner), i am running into the problem that the screenshots of the windows may be overlapped by other windows that just popped up or that are always brought to the front (e.g. splash screens). Bringing the window to the front does not really help.
There was an older similar thread not directly regarding to WPF applications, and sadly, without a clear solution: Taking screenshot of a partially hidden window in a programmatic way
Is there a way to get a "clean" screenshot, may be with the use of the windows AutomationElement instance?
I am working on a system for gesture recognition. My application is built on WPF C#. I want to make sure that when user gives proper gesture, a splash screen appears saying "Opening XYZ application" and then that application appears. From every thread that I have come across, I have learned that Splash screen is used in the application which is starting. Hence, it must be my own application where I can change the startup code by putting splash which will work before window_load event. I want a way to do this for third party software i.e. on making a gesture "C", Chrome should be opened with a splash screen in beginning mentioning "Opening Crome".
How can you tell when a windows 8 Metro app gets put in the background? The suspended state doesn't activate. I have a break point on. It only hits if I close the app.
I am using a webcam and since no apps can run in the background I need to save my work when it's put in the background.
The windows phone it was application deactivated.
any help would be nice.
Apps do not normally get suspended when in the debugger. However, you can force a suspend when debugging by:
Enabling the Debug Location toolbar (red arrow in image below).
Then press the Suspend button (blue arrow).
The suspending event should fire when the application is no longer active, namely, when another application is brought to the front. Presuming you're using C#/XAML, the app.xaml.cs file already has the Suspending event wired up. In HTML5/JavaScript it's checkpoint and you'll see it in default.js.
we have this application which uses cross app domain (2 app domains in the same process).
we need to mimic the Dialog/Model window, which will wait for the result from the 2nd app domain before it can continue further. 2nd App Domain loads up WPF form (while 1st app domain is still on .Net 2 forms). we will have to use this Plugins approach so that we can leverage our new WPF without breaking our old app.
at the moment I am using ManualEventReset to singal when the 2nd app domain is done, but this is freezing up the GUI so that when I move the Dialog/Model window, it is not repainting the background. Only happens on Windows XP (Windows 7 works fine)
I was wondering if there is a way to implement Model window so that it will still allow messages to go through so that background can repaint itself. Let me know if you need more specifics
you could open a regular modal form, that immediately hides itself and open the desired winforms form on another thread ... so you can "deadlock" one thread until your operation is complete without blocking the message processing of your UI ... to exit the modal state after your locked thread is released, invoke your hidden forms close() (Invoke() call to your UI thread)