C# Console Application Close Button vs Environment.Exit(0) - console

I have a server (Windows application) and a client (console application)
--- When I close the client application by closing close(red) button it updates the record instantly
--- but when I close the client application from server by sending command to invoke Environment.Exit(0) it closes the client application but doesn't update the record on server application...?
I would like to know that what does close button uses to terminate the application... Is it different?
and What should I use to exit console application?
Thanks in advance...

Related

Trino server running on Amazon EMR cluster but cannot access the web UI to view the queries execution and other stats that the web UI provides

I've verified my Trino server is properly working by looking at the server.log and observing there are no errors and the message "SERVER STARTED" appears. I've connected to my Trino server using JDBC connection in SQL workbench and can successfully run queries in there with data being returned. However, whenever I try to access the web UI to visibly SEE the query execution I get an error message saying "site can't be reached" "ERR_SSL_KEY_USAGE_INCOMPATIBLE". I've tested this on Trino 360 and Trino 388 and same issue persists. I've tried accessing web UI via DNS and IP address and both return the same result. Also, the same results are displayed whether i have "web-ui.enabled=true" in my config.properties or if I omit that property entirely. Has anyone experienced issues accessing Trino Web UI before? Any insight is greatly appreciated.
I am expecting web UI to come up for Trino server

WinRT/UWP is suspending rising on power off?

I am trying to save data before application (WinRT 8.1) close/sleep/minimze (or windows shutdown/restart in tablet with WIN10) using app suspending event.
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/suspend-an-app
However, it os not working on power off / shutdown WinRT/UWP: Is suspending action rising on long power off button holding?
The Suspending lifecycle event will fire in case of a normal OS shutdown - if you do Start -> Shut down.
This is unfortunately not the case with long power off button holding and restart button press, because both these are improper ways of shutting down your PC. Holding power button to shutdown essentially suddenly "cuts-down power" to the PC, which means the OS cannot respond to this and all unsaved data are lost. This method of shutting down a PC should be used only when something really bad happens and everything freezes. That is why the UWP app has no chance to run the suspending event handler in this case.
Is suspending action rising on long power off button holding?
System will shutdown forcibly with long press power off button. And the system could not make sure Current user session is finished. So the suspending event handler could not be invoked correctly.
From Windows 10 universal Windows platform (UWP) app lifecycle:
Current user session is based on Windows logon. As long as the current user hasn't logged off, shut down, or restarted Windows, the current user session persists across events such as lock screen authentication, switch-user, and so on.
So, before shut down, the app still in the Current user session. And Suspended will be invoked on power off(shut down).
Note, you can not test it in debug model within Visual Studio. Because when you shut down the system, Visual Studio will exit degbug model at first. The Suspended event will not be invoked as expect. You could verify with following code.
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var stringBulider = new StringBuilder();
var deferral = e.SuspendingOperation.GetDeferral();
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
Object value = localSettings.Values["exampleSetting"];
stringBulider.Append(value.ToString() + "/Next");
localSettings.Values["exampleSetting"] = stringBulider.ToString();
deferral.Complete();
}
Each time you shut down, the stringBulider will be append one at a time.

No eventlogs from BizTalk applications

I was trying out one functionality of BizTalk from the below link
https://masteringbiztalkserver.wordpress.com/category/pipelines/
Till now I never had to go to event log to check for any entries.
Now when I am trying to get a custom message logged in event Log, from BizTalk application, I dont see any relevent entry from BizTalk other than 2 entries when I restart the BizTalk Host instance.
From my research I had written down the below code in Expression shape in the application Orchestration:
xmlMessage = InputMessage;
stringMessage = xmlMessage.OuterXml;
System.Diagnostics.EventLog.WriteEntry("BizTalk Server", stringMessage);
Here the InputMessage is a message defined in orchestration for sample Schema that I have created.
My application got build and deployed properly and it is also processing the messages properly. Its just that I don't see any log in event viewer for my code or for the suspended messages when I intentionally stop the send port.
The discussionfrom below link also didnt help
No eventlogs from BizTalk
I have BizTalk Server configured on my Windows 7 Ultimate machine. I am the administrator of the machine.
A few points on this:
BizTalk sever will not log an event for a suspended message, that's why you dont' see one.
You should never use the BizTalk Server Event Source since the BizTalk product owns that
You can very easily create you own custom Event Source using PowerShell.
To create a custom Event Source, use something like:
new-eventlog -logname "Application" -Source "MyApplicationThatLogs"
To write with this Event Source, use something like:
System.Diagnostics.EventLog.WriteEntry("MyApplicationThatLogs", "Some Error Occured!", System.Diagnostics.EventLogEntryType.Error, 100, 0);
Rather than using System.Diagnostics.EventLog for debugging purposes I would recommend that you use the BizTalk CAT Instrumentation Framework.
For a pipeline
TraceManager.PipelineComponent.TraceInfo(stringMessage);
For a Orchestration
Microsoft.BizTalk.CAT.BestPractices.Framework.Instrumentation.TraceManager.WorkflowComponent.TraceInfo(stringMessage);
It allows for real-time tracing when needed, "you can enable tracing on a production server with only a negligible impact on performance (when tracing to a file)."

Stop Processing Of ASP.Net Web Form on Opening an Exe

In my ASP.net application, i have to open a EXE on click of button. When the EXE is open, User should not be allowed to perform any action on the web form, i.e. the exe should behave like a modal popup. I am using the current code to open and return value from EXE.
Dim p As Process
p = Process.Start("D:\VS2010Projects\SignatureCaptureWindows\bin\Debug\SignatureCaptureWindows.exe")
p.WaitForExit()
If (Not p.ExitCode.Equals(0)) Then
Response.Write("Image Successfully saved in Database with ID = " + p.ExitCode.ToString())
DisplaySavedImage(p.ExitCode)
End If
The Exe is opening fine and returning the correct value. However, the user is able to perform action on the web form when the exe is open...
What will be the best way to handle such a scenario ??
Its impossible to do the way you won it. From the moment the user send a submit, or try to open the page, and on code behind you run this exe, then user is wait for the results - in this time you can not make the user to not do anything else - you can not lock the browser, user can close it, reload it, open again the same page, etc.
What you can do is to lock this process using Mutex and not allow to run again if all ready run it.
Mutex on msdn with example : http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx

How to open a console app from a webform

I have a collection of sites running on a single server. The server also runs a console application which collects data and distributes this data to the websites.
I am not always about to check if the application is running and I would like to give the end user (a select few users!) the option to start/restart this application on the server by using a webform. (click a button and application starts).
I have got the console application to start by using the following code:
ProcessStartInfo info = new ProcessStartInfo(FileName);
Process App1 = null;
App1 = Process.Start(info);
But no console window appears and I would like the console to open a window so that if I log onto the server I can check that the application is running.
I have tried adding:
info.CreateNoWindow = false;
and a few other things, but this is not my area so I am struggling.
Any ideas how I can get the console to open in a normal window? Or am I going about this all the wrong way?
Also, is there a way of finding if the application is running and either kill it before trying to start it, just restarting it, or not allowing the end user the option to do anything.
Many thanks
T
As Aristos says, the console app will open on the server...not the client.
Look here for a start on how to open a process from asp and the security implications
If you need the client to be able to view anything I suggest having the service write to a log in a database and having the aspx page read this log.
Also, maybe write your console app as a windows service, not just an application?
Good example here
Hope this helps.
ProcessStartInfo info = new ProcessStartInfo(FileName);
Process App1 = null;
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
App1 = Process.Start(info);
try using info.usershellexecute property

Resources