IAsyncResult ar = request.BeginGetResponse(GetAsyncResponse, new object[] {request, id});

private void GetAsyncResponse(IAsyncResult result)
{
    object[] params = (object[])result.AsyncState;
    HttpWebRequest request = (HttpWebRequest)params[0];
    int id = (int)params[1];
    // process here
}

(0) Comments    Read More   
Posted on 09-03-2011
Filed Under (Csharp) by admin

Hata:
System.InvalidOperationException: Cross-thread operation not valid: Control ‘xlabel1′ accessed from a thread other than the thread it was created on.   at System.Windows.Forms.Control.get_Handle   at System.Windows.Forms.Control.set_WindowText   at System.Windows.Forms.Control.set_Text   at System.Windows.Forms.Label.set_Text   at tester.MainForm.test in c:\Users\tester\Documents\SharpDevelop Projects\tester\tester\MainForm.cs:line 48   at System.Threading.ThreadHelper.ThreadStart_Context   at System.Threading.ExecutionContext.Run   at System.Threading.ThreadHelper.ThreadStart

Çözüm:

//Add code :
CheckForIllegalCrossThreadCalls = false;
thread1.Start();

 

(0) Comments    Read More   
Posted on 19-08-2010
Filed Under (Csharp) by admin

Regex örneği yaratmak için System.Text kütüphanesini çağırmanız gerekiyor.

//..
                        string aranandesen = ".*
zuzu.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*[\r\n]+.*<a href="\">.*";
                        Regex arananRegex = new Regex(aranandesen);
                        MatchCollection benimMatchCollection = arananRegex.Matches(yazi);
			string bulunan;
                        foreach (Match benimMatch in benimMatchCollection)
                        {
				bulunan = benimMatch.Groups[1].ToString();
			}
//..
</a>

Msdn deki örnek kod dosyada düzenli ifadedeki deseni arıyor…

<a href="\">StreamReader sr = new StreamReader(filename);
string input;
string pattern = @"\b(\w+)\s\1\b";
while (sr.Peek() &gt;= 0)
{
   input = sr.ReadLine();
   Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
   MatchCollection matches = rgx.Matches(input);
   if (matches.Count &gt; 0)
   {
      Console.WriteLine("{0} ({1} matches):", input, matches.Count);
      foreach (Match match in matches)
         Console.WriteLine("   " + match.Value);
   }
}
sr.Close();   
</a>

Referans bağlantı:
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

(0) Comments    Read More