ZengCode.Com (The Thai Php Framework)  


Home   Download   Manual   About us  

MAIN MENU
News
Php Tips
Android Programming
Design Pattern By PHP
Linux Quick Tips
C# using Linq น่าใช้จริงๆ
C# Tips & Technique
Java & JavaScript Tips
Database
ZengCode Framework Guide
Zeng Code Code
Programming
IPhone (Tips and Trick)

 

สวัสดีครับแฟนๆ Madoogun.com ยินดีต้อนรับสู่บ้านใหม่ครับ

ZengCode framework ขอฝากเนื้อฝากตัวกับชาว Developer ทุกท่านด้วยนะครับ
ผู้พัฒนาเองไม่ได้หวังว่ามันจะใช้งานได้ดีขนาดไปเทียบกับจ้างยุทธจักรด้านนี้
ไม่ว่าจะเป็น Prado หรือแม้แต่ Cake ซึ่งนั้นเค้าระดับเทพเรียกพี่แล้วครับ
ผมก็เป็นแค่ Developer ธรรมดา ๆ คนนึงครับ
ที่สร้าง framework ตัวนี้ขึ้นมาก็เพื่อศึกษา และพัฒนาทักษะด้าน OOP ของตัวเอง
อีกทั้งปกติตัวผมเองเขียนโค้ดได้มั่วซั่วมาก ไม่มีระเบียบ อยากเขียนอะไรคิดออกก็เขียน
ไม่มีแบบแผน บางทีกลับมาแก้โค้ดตัวเอง บอกได้คำเดียวว่า เซ็งโครต เซ็ง โครต โครต
และนี่จึงเป็นที่มาของชื่อ framework ของผมครับ
และอีกประเด็นก็เพื่อจุดประการให้พี่น้องชาว Developer ทุกท่าน
ช่วยกันคิดพัฒนาสิ่งต่างๆ เพื่อวงการด้าน IT
ของเราได้ทัดเทียมนานาอารยะประเทศเค้านะคร ับผมขอเป็นจุดเล็กๆจุดนึงที่พร้อมจะมุ่งมั่น
พัฒนาผลงานด้านนี้ต่อไปครับ สู้ๆ นะพี่น้องชาว Developer ทุกท่าน

Happy New Year ขอให้ทุกท่านมีความสุขตลอดปี และตลอดไป ร่ำรวย ๆ กันทุกคนนะครับ

งานรับปริญา คลิกดูรูป


บทความล่าสุด

 Thread Synchronization (C# Programming Guide)  (2010-02-05)

นำไปประยุกต์ใช้กับ  multithreaded applications ในการเข้าถึง resources ที่ใช้ร่วมกันแบบง่ายๆ ก่อนนะครับ

อันแรกใช้ Lock Statement ครับ

For example:

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace SyncronizeThread
{

class Program
{
public static Int32 counter = new Int32();
static System.Object myLock = new object();
private static Mutex mut = new Mutex();

static void Main(string[] args)
{

counter = 1;
Thread t = new Thread(Run);
t.Name = "a";
t.Start();
t = new Thread(Run);
t.Name = "b";
t.Start();
t = new Thread(Run);
t.Name = "c";
t.Start();

Console.ReadKey();
}

public static void Run()
{
Console.WriteLine(Thread.CurrentThread.Name + " Starting ");
lock (myLock)
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(Thread.CurrentThread.Name + "===>" + (counter++));
Thread.Sleep(500);
}
}

}
}
}

[ThreadState Diagram]

อ่านต่อคลิกที่นี้


 จะควบคุม Windows Control ใน Thread ได้อย่างไร   (2010-02-04)

delegate void SetTextCallback(string text);

        private void setText(String text)
        {
            if (this.textBox1.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(setText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.textBox1.Text = text;
            }

        }

        private void Run2()
        {
            int i = 0;
            while (i <= 100)
            {
                this.setText("Number ==> "+i);
                i++;
                Thread.Sleep(2000);
            }
        }


อ่านต่อคลิกที่นี้


 How to: Make Thread-Safe Calls to Windows Forms Controls   (2010-02-04)

How to: Make Thread-Safe Calls to Windows Forms Controls 

 

If you use multithreading to improve the performance your Windows Forms applications, you must be careful to make calls to your controls in a thread-safe way.

Example

Access to Windows Forms controls is not inherently thread safe. If you have two or more threads manipulating the state of a control, it is possible to force the control into an inconsistent state. Other thread-related bugs are possible as well, including race conditions and deadlocks. It is important to ensure that access to your controls is done in a thread-safe way.

The .NET Framework helps you detect when you are accessing your controls in a manner that is not thread safe. When you are running your application in the debugger, and a thread other than the one which created a control attempts to call that control, the debugger raises an InvalidOperationException with the message, "Control control name accessed from a thread other than the thread it was created on."

This exception occurs reliably during debugging and, under some circumstances, at run time. You are strongly advised to fix this problem when you see it. You might see this exception when you debug applications that you wrote with the .NET Framework prior to .NET Framework version 2.0.

 

มาจาก msdn.microsoft.com/en-us/library/ms171728(VS.80).aspx


อ่านต่อคลิกที่นี้


 การส่งค่าให้ thread และรอรับค่าจาก thread ครับ  (2010-02-04)

โดยใช้ DELEGATE นะครับ ลองเอาไปประยุกต์กันดูนะครับ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

.........................................................................


อ่านต่อคลิกที่นี้


 TcpClient.Connect() timeout  (2010-02-04)

using (TcpClient tcp = new TcpClient())  
{  
    IAsyncResult ar = tcp.BeginConnect("127.0.0.1", 80, nullnull);  
    System.Threading.WaitHandle wh = ar.AsyncWaitHandle;  
    try 
    {  
       if (!ar.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5), false))  
       {  
           tcp.Close();  
           throw new TimeoutException();  
       }  
 
        tcp.EndConnect(ar);  
    }  
    finally 
    {  
        wh.Close();  
    }  

อ่านต่อคลิกที่นี้


 Reading Text File by LINQ  (2010-01-06)

Introduction

At times us developers have to deal with delimited text files in our applications. Such files have been around since yonks and I often come across data import/export tasks where delimited files are used. Till now the common way in .NET has been to read each line and then extract data using some sort of creative string functions within for loops. But there is another way by using LINQ. In this tutorial I will show you how to use LINQ to read such data. By the end of tutorial you will appreciate how easy and logical it is to use LINQ for reading data from delimited text files.

 

ที่มา : http://www.onedotnetway.com/tutorial-reading-a-text-file-using-linq/


อ่านต่อคลิกที่นี้


 Linq with ArrayList and List of user define Class  (2010-01-05)

......

......

static void Main(string[] args)
        {

            ArrayList al = new ArrayList();
            al.Add(new Person("Chiwa",25));
            al.Add(new Person("Chiwa2",26));
            al.Add(new Person("Chiwa3",27));
            al.Add(new Person("Chiwa4",28));

 .............

เอาไว้เป็นแนวทางนะครับ


อ่านต่อคลิกที่นี้


 Where - Simple  (2010-01-04)

Where - Simple 1

This sample prints each element of an input integer array whose value is less than 5. The sample uses a query expression to create a new sequence of integers and then iterates over each element in the sequence, printing its value.

public void Linq1() {
    int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

    var lowNums =
        from n in numbers
        where n < 5
        select n;

    Console.WriteLine("Numbers < 5:");
    foreach (var x in lowNums) {
        Console.WriteLine(x);
    }
}

Result

Numbers < 5:
4
1
3
2
0


อ่านต่อคลิกที่นี้


 Regular expressions  (2009-12-29)

เรื่องของ Regular expressions นั้นสามารถใช้ได้กับทุกภาษา โดยสำหรับ Javascript นั้นจะช่วยให้การพัฒนาเว็บไซท์ได้ โดยช่วยได้ในการกรองข้อมูลที่ผู้เข้าชมเว็บไซท์กรอกเข้ามา ซึ่งช่วยลดการทำงานของ webserver ลงได้เยอะมากครับ

การใช้งาน regular expressions นั้น จะต้องประกาศอยู่ภายใน /.../ โดยมีส่วนสำคัญอยู่ 2 ส่วน คือ

  1. Flag เป็นตัวที่บอกว่า pattern ที่ต้องการเปรียบเทียบนั้นจะใช้แบบใด โดยมี
    • g เป็นการเปรียบเทียบแบบ case-sensitive
    • i เป็นการเปรียบเทียบแบบ case-insensitive
    • m เป็นการเปรียบเทียบแบบหลายบรรทัด *
    • s เป็นการเปรียบเทียบแบบบรรทัดเดียว *
    • x เป็นการเปรียบเทียบแบบไม่สนใจช่องว่าในข้อความ *
    * ไม่สามารถใช้ได้กับ Netscape Navigator 4 และ Internet Explorer 4
  2. Pattern เป็นรูปแบบที่ต้องการเปรียบเทียบ โดยแบ่งออกเป็น
    • Charactor matching
      • ชนิดตัวอัษร ประกอบด้วย a..z, A..Z, 0..9, \
      • ชนิด Unicode ฐาน 16 ประกอบด้วย \u0000...\uFFFF
      • ชนิด ASCII ฐาน 16 ประกอบด้วย \x00...\xFF
      • ชนิด Control charactor ประกอบด้วย \cA...\cZ
      • \0 เทียบได้กับ Null charactor \x00
      • [\b] เทียบได้กับ Back space \x08
      • \t เทียบได้กับ tab \x09
      • \r เทียบได้กับ carriage return \x0D
      • \n เทียบได้กับ newline \x0A

อ่านต่อคลิกที่นี้


 Make Thread-Safe Calls to Windows Forms Controls   (2009-12-28)

ตัวอย่างนี้ผมให้ thread เขียน TextBox นะครับ ทดสอบแล้วใช้งานได้ครับ แต่ code อาจจะไม่ค่อยดีนะครับ
ชี้แนะได้นะครับ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;


namespace TestThread
{
    public partial class Form1 : Form
    {
        delegate void SetTextCallback(string text);


อ่านต่อคลิกที่นี้


easy tracking
avis car rental discount code

This page took 0.008575 seconds to load.