www.flickr.com
Showing posts with label sample programs. Show all posts
Showing posts with label sample programs. Show all posts

How to kill your program's process in Task Manager (VB.NET/C#) ?

Saturday, December 14, 2013 Posted by Glenn 5 comments

Getting pretty baffled on your C# or vb.NET programs? Your program is in the process in task manager although all of the windows are already closed? I already made several "quite"-big projects in vb.NET and seriously, such problem is really a pain the arse. :) But now, I'm learning C# and currently developing my program called: "Employee Locator v2.0". Anyways, I would like to share this solution that I've recently found out. After an hour, I finally solved my problem haha!

By the way, this program opens first its splashscreen, which of course let the user be informed what is going on in the background. During such duration of splashing such splashscreen, the user can close the program instantly, just like in MS Office 2013. Now, as soon as the user clicks the X button, the program is supposed to be closed and cleared in the Task Manager.




Also, if the main window is to be closed by the user, the program shouldn't be displaying in the Task Manager Processes.
So, after several steps and changing of codes, I finally got the answered. In order to be sure: I executed these two steps:

1. As I've said, if the x button in the splashscreen is clicked, the whole program is killed! --- CHECKED!
2. If the Main Window is closed (X button is clicked), the whole program should also be killed! --- CHECKED!

SOLUTION:
1. Go to App.xaml, set your shutdownmode: (note that my StartupUri is set to my SplashScreen)

ShutdownMode="OnLastWindowClose"

2. In your MainWindow XAML, add this:

Closing="Window_Closing" Closed="Window_Closed"

3. Finally, make a closing handle event in your MainWindow.xaml.cs

       private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            System.Environment.Exit(0);
         }

        private void Window_Closed(object sender, EventArgs e)
        {
            System.Environment.Exit(0);
        }

There are lots of ways to solve this, I know :). In order to be sure and avoid more debugging, I just doubled my event handlers. The Window_Closing and the Window_Closed.

article by: Glenn Posadas

additional tags: WPF in C#.NET, how to handle closing events, how to close all the apps in C# and VB.NET, VB.NET/C# closing events, closing events in C# WPF, WPF C# close all process after closing windows, C# WPF SplashScreen problems.

Sharing is so Easy:
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google Twitter FaceBook

Codes for Trapezoidal Rule in C and C++

Tuesday, October 15, 2013 Posted by Glenn 0 comments

 #include<stdio.h>  
 #include<conio.h>  
 #include<math.h>  
 float fn(float x)  
 {  
 sqrt(x);  
 return sqrt(x);  
 }  
 main()  
 {  
 int i,n;  
 float a,b,s=0,y=0,h;  
 printf("Enter the no of interval =");  
 scanf("%d",&n);  
 printf("Enter the lower limit=");  
 scanf("%f",&a);  
 printf("Enter the upper limit=");  
 scanf("%f",&b);  
 h=(b-a)/n;  
 for(i=1;i<=n-1;i++)  
 {  
 s=s+fn(a+i*h);  
 }  
 y=(fn(a)+fn(b)+2*s)*h/2;  
 printf("the value of y is=%f",y);  
 getch();  
 }  

-this source codes belongs to: the author of wbutassignmenthelp :)
-this source codes is ready for copy-paste to any IDE/compilers for C/C++. The quotations from the original website source confuse the compilers, I've already change them to the original quotation :)
additional tags: trapezoidal rule for C, trapezoidal rule for Cplusplus, C++, codes for Trapezoidal, trapezoidal source codes

Sharing is so Easy:
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google Twitter FaceBook

Assembly Language 8086 determine if a character is capital or small

Wednesday, August 1, 2012 Posted by Glenn 1 comments

additional tags: determine if the character is small or capital, assembly programming 8086 sample program, character tutorial in assembly program language 8086, determine if capital or small characters in assembly 8086

Sharing is so Easy:
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google Twitter FaceBook

Convert Password input into Asterisk in C, C++

Saturday, November 12, 2011 Posted by Glenn 0 comments

Here is my source code about converting the inputted password into asterisk * in C and C++




#include "iostream.h"
#include "conio.h"
#include "cstring.h" // for strcmp

using namespace std;
int main(void)
{
int c;
int i;
char pw[80];
start:

printf("\n1Enter Password:");

for ( i = 0; i < 79 && (c = getch()) != '\r'; ++i ) {
pw[i] = c;
putch('*');
}

pw[i] = '\0';


if ( strcmp(pw, "CORRECT") == 0 ) {
printf("\nPASSWORD CORRECT");
} else {
goto start;
}
getch();

return 0;
}

Sharing is so Easy:
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google Twitter FaceBook

Convert a string into capital Assembly Language

Saturday, October 29, 2011 Posted by Glenn 0 comments

;ASK FOR STRING
;CONVERT THE STRING TO CAPITAL
;author: glenn posadas www.glennvon.com

@ps macro st
mov ah,09h
lea dx, st
int 21h
endm

@pc macro var
mov ah,02h
mov dl,var
int 21h
endm

cseg segment para 'code'
assume cs:cseg,ds:cseg,es:cseg,ss:cseg
org 100h


start: jmp begin
glenn db ?

;-----------------
s1 label byte
maxlen db 41 ; 40 is max
len db ?
val db 41 dup(?)
;--------------------

s2 db 'Enter a string(small caps max:40): $'
s3 db 10,13,'Input: $'
s4 db 10,13,'Output: $'

count db ?
madeline db ? ;holds the characters

begin:

mov ax,03h
int 10h

@ps s2
mov ah,0Ah
lea dx,s1
int 21h


@ps s3 ;display na ung ininput
lea bx,val
mov al,len ;transfer muna dito, kasi bawal ang len to count
mov count,al

iput: ;input
mov al,[bx] ;ililipat mo ung isaisang laman ng bx sa al,tapos inc bx
mov madeline,al
@pc madeline
inc bx
dec count
cmp count,0
jnz iput


@ps s4
lea bx,val
mov al,len
mov count,al

oput: ;output
mov al,[bx]
mov madeline,al
sub madeline,32
@pc madeline
inc bx
dec count
cmp count,0
jnz oput
je exit



exit:

int 20h
cseg ends
end start

Sharing is so Easy:
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google Twitter FaceBook