Click here to Skip to main content
15,886,007 members
Articles / General Programming / Threads

Declarative multithreading

Rate me:
Please Sign up or sign in to vote.
4.94/5 (39 votes)
13 Mar 2012CDDL19 min read 57.8K   862   139  
An introduction and proof of concept code for the idea of declarative multi threading in C#.
namespace FormsTest
{
    partial class MainForm
    {
        /// <summary>
        /// Designer variables.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Ressources.
        /// </summary>
        /// <param name="disposing">True, if managed ressources should be disposed.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Vom Windows Form-Designer generierter Code

        /// <summary>
        /// Erforderliche Methode für die Designerunterstützung.
        /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
        /// </summary>
        private void InitializeComponent()
        {
            this.BtnStart = new System.Windows.Forms.Button();
            this.LBNumbers = new System.Windows.Forms.ListBox();
            this.BtnCancel = new System.Windows.Forms.Button();
            this.BtnDispose = new System.Windows.Forms.Button();
            this.BtnStartState = new System.Windows.Forms.Button();
            this.BtnCancelState = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // BtnStart
            // 
            this.BtnStart.Location = new System.Drawing.Point(12, 12);
            this.BtnStart.Name = "BtnStart";
            this.BtnStart.Size = new System.Drawing.Size(136, 23);
            this.BtnStart.TabIndex = 0;
            this.BtnStart.Text = "CreateNumbers";
            this.BtnStart.UseVisualStyleBackColor = true;
            this.BtnStart.Click += new System.EventHandler(this.BtnStart_Click);
            // 
            // LBNumbers
            // 
            this.LBNumbers.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.LBNumbers.FormattingEnabled = true;
            this.LBNumbers.Location = new System.Drawing.Point(12, 80);
            this.LBNumbers.Name = "LBNumbers";
            this.LBNumbers.Size = new System.Drawing.Size(298, 173);
            this.LBNumbers.TabIndex = 1;
            // 
            // BtnCancel
            // 
            this.BtnCancel.Location = new System.Drawing.Point(154, 12);
            this.BtnCancel.Name = "BtnCancel";
            this.BtnCancel.Size = new System.Drawing.Size(75, 23);
            this.BtnCancel.TabIndex = 2;
            this.BtnCancel.Text = "Cancel";
            this.BtnCancel.UseVisualStyleBackColor = true;
            this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
            // 
            // BtnDispose
            // 
            this.BtnDispose.Location = new System.Drawing.Point(235, 12);
            this.BtnDispose.Name = "BtnDispose";
            this.BtnDispose.Size = new System.Drawing.Size(75, 23);
            this.BtnDispose.TabIndex = 3;
            this.BtnDispose.Text = "Dispose";
            this.BtnDispose.UseVisualStyleBackColor = true;
            this.BtnDispose.Click += new System.EventHandler(this.BtnDispose_Click);
            // 
            // BtnStartState
            // 
            this.BtnStartState.Location = new System.Drawing.Point(12, 41);
            this.BtnStartState.Name = "BtnStartState";
            this.BtnStartState.Size = new System.Drawing.Size(136, 23);
            this.BtnStartState.TabIndex = 4;
            this.BtnStartState.Text = "CreateNumbers (State)";
            this.BtnStartState.UseVisualStyleBackColor = true;
            this.BtnStartState.Click += new System.EventHandler(this.BtnStartState_Click);
            // 
            // BtnCancelState
            // 
            this.BtnCancelState.Location = new System.Drawing.Point(154, 41);
            this.BtnCancelState.Name = "BtnCancelState";
            this.BtnCancelState.Size = new System.Drawing.Size(156, 23);
            this.BtnCancelState.TabIndex = 5;
            this.BtnCancelState.Text = "Cancel (State)";
            this.BtnCancelState.UseVisualStyleBackColor = true;
            this.BtnCancelState.Click += new System.EventHandler(this.BtnCancelState_Click);
            // 
            // MainForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(322, 262);
            this.Controls.Add(this.BtnCancelState);
            this.Controls.Add(this.BtnStartState);
            this.Controls.Add(this.BtnDispose);
            this.Controls.Add(this.BtnCancel);
            this.Controls.Add(this.LBNumbers);
            this.Controls.Add(this.BtnStart);
            this.Name = "MainForm";
            this.Text = "Declarative Mutlithreading Test";
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button BtnStart;
        private System.Windows.Forms.Button BtnCancel;
        public System.Windows.Forms.ListBox LBNumbers;
        private System.Windows.Forms.Button BtnDispose;
        private System.Windows.Forms.Button BtnStartState;
        private System.Windows.Forms.Button BtnCancelState;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Systems Engineer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions