Click here to Skip to main content
15,909,193 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
For example i have simple WPF application.Just window and nothing more.And i see that there are seven threads in application.What do this threads does?In Console Application 4 threads.I don't understand this also.I using Task manager to determine this.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication2
{
    
    static class swticher
    {
       
    
    }
    static class moves
    {
        public static double devide(double a, double b)
        {
            return a / b;
        }
        public static double plus(double a, double b)
        {
            return a + b;
        }
        public static double multiply(double a, double b)
        {
            return a * b;
        }
        public static double minus(double a, double b)
        {
            return a - b;
        }
        public static double sinus(double a)
        {
            return Math.Sin(a);
        }
    }
    public partial class MainWindow :Window

    {
        string Leftoperand = "";
        string Rightoperand = "";
        char Operator = ' ';
        int isok=0;
        bool b=false;
        public MainWindow()
        {
          
        }
        public void Somemethod(object e,EventArgs args)
        {
           
        }

        public void Buttonmove(object sender, RoutedEventArgs e)
        {
            string s = (string)((Button)e.OriginalSource).Name;
            if (s == "Buttonshift")
                b = !b;
            if (b == false)
                swither1(s);
            else
                swither3(s);
        }

        private void Window1_KeyDown_1(object sender, KeyEventArgs e)
        {
            swither2(e);
        }
        public  void swither1(string s)
        {
            switch (s)
            {
                case "Button0": Screen.Text += "0"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "0"; else Rightoperand += "0"; break;
                case "Button1": Screen.Text += "1"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "1"; else Rightoperand += "1"; break;
                case "Button2": Screen.Text += "2"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "2"; else Rightoperand += "2"; break;
                case "Button3": Screen.Text += "3"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "3"; else Rightoperand += "3"; break;
                case "Button4": Screen.Text += "4"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "4"; else Rightoperand += "4"; break;
                case "Button5": Screen.Text += "5"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "5"; else Rightoperand += "5"; break;
                case "Button6": Screen.Text += "6"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "6"; else Rightoperand += "6"; break;
                case "Button7": Screen.Text += "7"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "7"; else Rightoperand += "7"; break;
                case "Button8": Screen.Text += "5"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "8"; else Rightoperand += "8"; break;
                case "Button9": Screen.Text += "6"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "9"; else Rightoperand += "9"; break;
                case "Buttonsin": if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) 
                { Leftoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Leftoperand))); Screen.Text = Leftoperand; } 
                else { Rightoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Rightoperand))); Screen.Text = Rightoperand; } break;
                case "ButtonDEL": if (isok == 0 && Leftoperand.Length > 0) { Leftoperand = Leftoperand.Remove(Leftoperand.Length - 1); Screen.Text = Leftoperand; } else { if (Rightoperand.Length > 0) { Rightoperand = Rightoperand.Remove(Rightoperand.Length - 1); Screen.Text = Rightoperand; } } break;
                case "Buttonpoint": Screen.Text += ","; if (isok == 0 && Leftoperand.Length <= 10) Leftoperand += ","; else Rightoperand = ","; break;
                case "Buttonx": Screen.Text = ""; isok = 1; Operator = 'x'; break;
                case "Buttonplus": Screen.Text = ""; isok = 1; Operator = '+'; break;
                case "Buttonminus": Screen.Text = ""; isok = 1; Operator = '-'; break;
                case "Buttondevide": Screen.Text = ""; isok = 1; Operator = '/'; break;
                case "ButtonClear": Screen.Text = ""; isok = 0; Operator = ' '; Leftoperand = ""; Rightoperand = ""; break;

                case "ButtonEqual": if (isok == 1)
                    {
                        Screen.Text = "";
                        switch (Operator)
                        {
                            case 'x': Leftoperand = Convert.ToString(moves.multiply(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '/': Leftoperand = Convert.ToString(moves.devide(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '-': Leftoperand = Convert.ToString(moves.minus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '+': Leftoperand = Convert.ToString(moves.plus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                        }
                    } break;
            }
        }
        public void swither2(KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.D0: Screen.Text += "0"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "0"; else Rightoperand += "0"; break;
                case Key.D1: Screen.Text += "1"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "1"; else Rightoperand += "1"; break;
                case Key.D2: Screen.Text += "2"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "2"; else Rightoperand += "2"; break;
                case Key.D3: Screen.Text += "3"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "3"; else Rightoperand += "3"; break;
                case Key.D4: Screen.Text += "4"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "4"; else Rightoperand += "4"; break;
                case Key.D5: Screen.Text += "5"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "5"; else Rightoperand += "5"; break;
                case Key.D6: Screen.Text += "6"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "6"; else Rightoperand += "6"; break;
                case Key.D7: Screen.Text += "7"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "7"; else Rightoperand += "7"; break;
                case Key.D8: Screen.Text += "8"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "8"; else Rightoperand += "8"; break;
                case Key.D9: Screen.Text += "9"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "9"; else Rightoperand += "9"; break;
                case Key.Back:if (isok == 0 && Leftoperand.Length > 0) { Leftoperand = Leftoperand.Remove(Leftoperand.Length - 1); Screen.Text = Leftoperand; } else { if (Rightoperand.Length > 0) { Rightoperand = Rightoperand.Remove(Rightoperand.Length - 1); Screen.Text = Rightoperand; } } break;
                case Key.OemComma: Screen.Text += ","; if (isok == 0 && Leftoperand.Length <= 10) Leftoperand += ","; else Rightoperand += ","; break;
                case Key.S: if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) 
                { Leftoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Leftoperand))); Screen.Text = Leftoperand; } 
                else { Rightoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Rightoperand))); Screen.Text = Rightoperand; } break;
                case Key.Multiply: Screen.Text = ""; isok = 1; Operator = 'x'; break;
                case Key.OemPlus: Screen.Text = ""; isok = 1; Operator = '+'; break;
                case Key.OemMinus: Screen.Text = ""; isok = 1; Operator = '-'; break;
                case Key.Divide: Screen.Text = ""; isok = 1; Operator = '/'; break;
                case Key.Escape: Screen.Text = ""; isok = 0; Operator = ' '; Leftoperand = ""; Rightoperand = ""; break;

                case Key.LeftCtrl: if (isok == 1)
                    {
                        Screen.Text = "";
                        switch (Operator)
                        {
                            case 'x': Leftoperand = Convert.ToString(moves.multiply(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '/': Leftoperand = Convert.ToString(moves.devide(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '-': Leftoperand = Convert.ToString(moves.minus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '+': Leftoperand = Convert.ToString(moves.plus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                        }
                        Rightoperand = "";
                    } break;
            }
        }
        public void swither3(string s)
        {
            switch (s)
            {

                case "ButtonEqual": if (isok == 1)
                    {
                        Screen.Text = "";
                        switch (Operator)
                        {
                            case 'x': Leftoperand = Convert.ToString(moves.multiply(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '/': Leftoperand = Convert.ToString(moves.devide(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '-': Leftoperand = Convert.ToString(moves.minus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                            case '+': Leftoperand = Convert.ToString(moves.plus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
                        }
                    } break;
            }
        }
    }
}

XML
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Title="My program" x:Class="WpfApplication2.MainWindow" x:Name="Window1" Height="500" Width="500" ResizeMode="NoResize" KeyDown="Window1_KeyDown_1">
    <Window.Background>
        <ImageBrush ImageSource="pack://application:,,,/Resources/Somecalculator.jpg"/>
    </Window.Background>
    <Grid>
        <TextBlock Margin="126,76,126,330" removed="White" x:Name="Screen" FontSize="40"/>
        <Button Opacity="0" Margin="116,314,324,130" x:Name="Button7" Click="Buttonmove" />
        <Button Opacity="0" Margin="116,350,324,99" x:Name="Button4"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="116,381,324,68" x:Name="Button1"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="116,412,324,37" x:Name="Button0"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="170,319,274,135" x:Name="Button8"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="170,352,274,102" x:Name="Button5"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="170,383,274,71" x:Name="Button2"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="170,416,274,38" x:Name="Buttonpoint"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="222,319,222,135" x:Name="Button9"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="222,351,222,103" x:Name="Button6"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="222,383,222,71" x:Name="Button3"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="275,351,169,103" x:Name="Buttonx"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="275,383,169,71" x:Name="Buttonplus"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="328,350,116,104" x:Name="Buttondevide"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="330,381,114,71" x:Name="Buttonminus"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="328,412,116,38" x:Name="ButtonEqual"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="328,315,116,135" x:Name="ButtonClear"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="275,317,169,133" x:Name="ButtonDEL"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="249,263,204,194" x:Name="Buttonsin"   Click="Buttonmove"/>
        <Button Opacity="0" Margin="114,170,339,281" x:Name="Buttonshift"   Click="Buttonmove"/>
    </Grid>
</Window>
Posted
Updated 22-Feb-15 7:28am
v2
Comments
Afzaal Ahmad Zeeshan 22-Feb-15 13:09pm    
Probably a few threads that are required by .NET framework to run your application; WPF, Console application they all run over .NET framework.
Inimicos 22-Feb-15 13:19pm    
I am glad that you understood my quastion in spite of my english.I want to learn more about it in details.
Sergey Alexandrovich Kryukov 22-Feb-15 13:20pm    
What does it mean "I have"? Is it your application or not? Later, you write "I see that there are seven threads...". If you just see it and are not sure what they do, it suggest that the application is not yours? But why then we should attend to your question at all? You can find any kind of application who-knows-there, so why should any one who did not even see those applications get any interest in who-knows-what? I am not even sure if you have source code or not.
—SA

1 solution

Please see my comment to your question which explains why it makes no sense. I would even say that your post is abuse; not violation of any rules, but abuse of normal common sense and logic.

But here is the answer to your question: the threads you observed could be used by the author of the application (assuming it is reasonable) to solve various problems which had to be solved asynchronously to each other. Most typical reasons: having to implement logically independent flows of instructions and to support the user's activity via the UI without delays.

But that could be the purposes of the author of that application, not you. You are not the one who was fully qualified even for asking this question.

Any advise? Well, if you are interested in software development, start to learn it. Write your own applications and, if you face real problems, ask us some real questions. We will gladly try to help.

[EDIT]

After you exposed some of source code to us, I can tell: your question makes even little sense that I would assume initially. Note that the work "thread" is mentioned only once, in "using" clause, which says that this namespace and assembly is not actually used.

That said: not only you are showing who-knows-what, you are showing a pretty low quality application (but just due to this simple flaw). What's the purpose of looking at it? I would say, just wasting your time.

—SA
 
Share this answer
 
v3
Comments
Inimicos 22-Feb-15 13:32pm    
This application only mine.Source code is above.And if you think that i can't do nothing.And i ask quastion,becouse i don't know what to do.You don't right.I didn't create any threads by myself and that's why.I asked you,why there are 7 threads and what does they do.I can explain all rows of this code,if you don't believe me.
Sergey Alexandrovich Kryukov 22-Feb-15 13:34pm    
I cannot understand it. How can you write an application without knowing what your threads do?
—SA
Inimicos 22-Feb-15 13:43pm    
I didin't create any threads here.By the way thread is creating by following code.Thread nameofthread=new Thread(<name of="" method="">); etc.I know that i didn't create any threads here.But i see that my application use 7 threads in task manager.You can see that i don't even use System.Threading namespace here.
Sergey Alexandrovich Kryukov 22-Feb-15 13:55pm    
No, 1) this is not the only way to create a thread; 2) some threads are added indirectly; for example, WPF application run adds rendering thread, using file dialog showing adds another thread, things like that...
From your code, we don't know all the detail...
—SA
Inimicos 22-Feb-15 14:08pm    
That's what i wanted to ask.I am about second point.About threads that's create indirectly.I agree my quastion is bad and is not undrstantable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900