How to clear notifications in IOS using Objective-C

To clear notifications in IOS using objective-c you can use the snippet below.

Sample Objective-C

//in method: application:didFinishLaunchingWithOptions
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

//in method: application:didReceiveRemoteNotification
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1]; //we need to to increment first
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

How to check if a Form is Open in C# and VB.NET

To Check if a Form is open in C# and VB.NET you can use the snippet below.

Sample C#

public static bool FormIsOpen(FormCollection application, Type formType)
{
	//usage sample: FormIsOpen(Application.OpenForms,typeof(Form2)
	return Application.OpenForms.Cast<Form>().Any(openForm => openForm.GetType() == formType);
}

Sample VB.NET

Public Shared Function FormIsOpen(application__1 As FormCollection, formType As Type) As Boolean
	'usage sample: FormIsOpen(Application.OpenForms,GetType(Form2)
	Return Application.OpenForms.Cast(Of Form)().Any(Function(openForm) openForm.[GetType]() = formType)
End Function

How to get the path of the active app.config file in C# and VB.NET

To get the path of the active app.config file in C# and VB.NET you can use the following snippet

Sample C#

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

Sample VB.NET

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

How to exit an application in C# and VB.NET

To exit an application in C# and VB.NET you can use the following snippet.

Sample C#

System.Windows.Forms.Application.Exit(0); // WINFORM
Environment.Exit(0); // CONSOLE APP
Application.Shutdown(); // WPF

Sample VB.NET

System.Windows.Forms.Application.[Exit](0) ' WINFORM
Environment.[Exit](0) ' CONSOLE APP
Application.Shutdown() ' WPF

How to start a process and wait for exit in Powershell

To start a application and wait for exit in Powershell you can use the following snippet.

Sample Powershell

start-process -filepath "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" -Wait -NoNewWindow -argumentlist '-args'

for more informations take a look at the MSDN Start-Process

How to check if a form is already open in C# and VB.NET

To check if a form is already open in C# and VB.NET you can use the following snippet.

Sample C#

public static bool IsFormOpen(Type FormType)
{
	foreach (var OpenForm in Application.OpenForms)
	{
		if (OpenForm.GetType() == FormType)
		{
			return true;
		}
	}
	return false;
}

Sample VB.NET

Public Shared Function IsFormOpen(FormType As Type) As Boolean
	For Each OpenForm As var In Application.OpenForms
		If OpenForm.GetType() = FormType Then
			Return True
		End If
	Next
	Return False
End Function

How to restart a Application in C# or VB.NET

To restart a Application in C# or VB.NET you can use the following line of code.

Sample C#

Application.Restart();

Sample VB.NET

Application.Restart

for more informations see the MSDN: Application.Restart Method