WinForms OnInputLanguageChanging is not raised - c#

I'm trying to override
protected override void OnInputLanguageChanging(System.Windows.Forms.InputLanguageChangingEventArgs e)
{
}
In my Main Form class C# app (Tested on .NET Framework 4.7.2 and 4.8)
The expectation is to have it called, when the user tries to change the Windows language. Unfortunatelly it doesn't work, the method is not called, however the method OnInputLanguageChanged works perfectly but it's too late for me.
Is there any trick to have OnInputLanguageChanging working?
Thanks

Related

Is it possible to run c# script code before application starts in Unity

I have a library made for Unity that needs to run some codes at Application's onCreate (Its callback interface must be added at application creation). The code must be entered by user's who are going to use my library.
My question is: Is it possible to run the user's C# code at the Application's oncreate?
Consider this code:
public class MyApplication extends android.app.Application {
#Override
public void onCreate() {
MyLibrary.setCallBack(new Callback {
#Override
void onSuccess() {
// Here some code must be entered by user
// Since library is for Unity it should be a c# code that user has written
}
});
}
}
How can user add c# code that can be entered there when app starts?
Thanks in advance.
As a short answer, no.
The whole Unity Engine needs to be up and running for any code using UnityEngine namespace (that is pretty much all unity code) to be functional. Unity needs to set up the context, allocate memory, get the Mono running etc, before the first line of code from the user gets executed.
In normal circumstances this is appropriate, maybe you can allow callback exchange at a later point of the application lifetime?

Using Interactive Toast Notifications with a old WPF Project

I have a working program which opens Dialog Boxes(WPF) for User input .
Now i want to Refactor and use Toast Notifications. The Notifications need to have the ability of Buttons (Pressing yes or no). The new Win10 interactive Toast Notification seemd perfect.
I got the official tutorial from Windows.
https://learn.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-send-local-toast
Displaying the Toasts works fine but.... The Programm is a in Visual Studio WPF App(.NET Framework) written in C#.
It won't allow me to override methods in my App.xaml.cs i need like:
protected override void OnActivated(IActivatedEventArgs e)
protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args)
"There is no suitable Method for override"
Simply because there is none ...i think?!
As soon as i tried with a new Project "Blank App univeral Windows" exept from "WPF App .NET Framework" overriting is no problem. Also new created WPF Apps won't let me override.
So my question. What can i do to still use interactive Toasts with my WPF Project? Or is there a alternative way of doing it?

In which namespace Application.OnLaunched is located?

I am trying to add HockeyApp to my WPF app, but cannot find Application.OnLaunched ?
Any thought appreciated thanks!
https://support.hockeyapp.net/kb/client-integration-windows-and-windows-phone/hockeyapp-for-applications-on-windows#crash-reporting
For platforms other than UWP, you need to add the following line of
code at the end of the OnLaunched(LaunchActivatedEventArgs e) Method
(in App.xaml.cs)
It seems, that KB page is incorrect. There's no OnLaunched method in WPF Application class. The nearest equivalent will be OnStartup.
Note, that Silverlight Application differs from WPF one - you need to handle Startup event, because there's no virtual OnStartup method there.
it is located in the system.windows.application

WPF Entity Framework Loading Process Stucks

currently i am working with the project in C# WPF with entity framework, i had used MahApps.Metro package for UI, i need to implement the ProgreeBar or LoadingIndicator or anything that idicates that my app is not stuck,
Whenever i made any kind of operation first time, my apps stucks for few second and it seems like its hang,
In web apps i had implemented AJAX call, loading process with
.ajaxStart()
.ajaxStop()
So my question is does anyone know or is there any way to implement every call of app or entity framework or any process how can i implement ProgressBar or GIF Loader or anything that shows process.
I had tries ProgessBar of MahApps.Metro but whenever I start that ProgressBar it Stucks untill that process complete.
EDITED:
Some of Code is,
private void ShowClientWindow(object sender, RoutedEventArgs e)
{
myProgess.IsIndeterminate = true; //its for progressbar
myFrame.Source = new Uri("MyViews/ClientView.xaml", UriKind.Relative);
myProgess.IsIndeterminate = false;
}
Thanks,
Gaurav Oza
The solution is not to display a ProgressBar to let the user think the application is not stuck, but to use async calls to actually avoid being stuck.
Entity Framework 6 does support async query and save

How to catch any type of application exit?

I have a WPF application.
I have implemented the following function, but no one catches all type of application exits.
public partial class App : Application
{
protected override void OnExit(ExitEventArgs e)
{}
private void Application_Exit(object sender, ExitEventArgs e)
{}
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{}
private void Application_SessionEnding(object sender, SessionEndingCancelEventArgs e)
{}
}
Is there a generic way to handle application exit?
For example none of above methods fires when application is forced closed (killed).
Each time application closes, I need to unlock some objects in database that is locked by user during application run.
You cannot catch all types of exists unless you are running an observer, separate from your application being surveyed (the "target" application).
The reason being you cannot internally catch application crashes (duh), forced process termination (both internal and external) or anything to that effect.
What you have done is perfectly good.
If you do wish to implement a separate observer application, you can use the .NET Process.Exited event, which is fired whenever a process exists for any reason, including application crashes.
Also, as #Christian has pointed out, you should not try to have a catch-all solution, especially when dealing with critical application crashes (this point is subjective). " When you somehow manage [to recover from an unhandled application error], you're usually doing something wrong or at least may get inaccurate results (e.g. when trying to P/Invoke a minidump creation from your own process)."
You can attach a handler to the AppDomain.ProcessExit event; as far as I can tell, it's the most reliable way to tell when your application is exiting.
This won't be available if you move your app to Silverlight, but as long as you stay within WPF (or any other "full-sized" .NET framework app) this should do the trick.

Categories

Resources