using System;
using System.Text;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
namespace Threading_Demo
{
public class Threading
{
ArrayList data = null;
ManualResetEvent[] totalEvents = null;
public Threading(ArrayList data)
{
this.data = data;
this.totalEvents = new ManualResetEvent[data.Capacity];
}
public void ProcessThreads()
{
WaitCallback callBack = new WaitCallback(ProcessData);
int resetIndex = 0;
foreach (object item in data)
{
//Create thread and add it in pool
ThreadPool.QueueUserWorkItem(callBack, resetIndex + "#" + item);
//Create new event
totalEvents[resetIndex++] = new ManualResetEvent(false);
}
if (totalEvents != null)
{
WaitHandle.WaitAll(totalEvents);
}
}
private void ProcessData(object state)
{
string objState = state as string;
string[] stateParam = objState.Split('#');
if (stateParam.Length == 2)
{
int threadId = Convert.ToInt32(stateParam[0]);
if (!string.IsNullOrEmpty(stateParam[1]))
{
string data = stateParam[1];
//Process data
Console.Write("Thread Id: " + threadId.ToString() + " Data: " + data.ToString() + "\n");
//Signal to pool after current thread finished it's porceesing
totalEvents[threadId].Set();
}
}
}
}
class Program
{
static void Main(string[] args)
{
ArrayList data = new ArrayList(5) { "One", "Two", "Three", "Four", "Five"};
Threading thread = new Threading(data);
thread.ProcessThreads();
}
}
}
Wednesday, September 26, 2012
Threading example in C#
Tuesday, July 17, 2012
SharePoint Server 2013 released in preview along with Pro and Developer training materials
Today is good news for SharePoint professionals, finaly Microsoft released SharePoint new version that is SharePoint Server 2013 in preview edition, though it's preview we get chance to look into it and play with new features
Here below are few usefull links
SharePoint 2013 new features and capabilities
SharePoint 2013 training for developers
What's new for developers in SharePoint 2013
Download Microsoft SharePoint Server 2013 Preview
Here below are few usefull links
SharePoint 2013 new features and capabilities
SharePoint 2013 training for developers
What's new for developers in SharePoint 2013
Download Microsoft SharePoint Server 2013 Preview
Tuesday, January 10, 2012
Find all ContentByQueryWebParts from the page programatically
Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager manager = web.GetLimitedWebPartManager("Pages/default.aspx", PersonalizationScope.Shared);
foreach (Microsoft.SharePoint.WebPartPages.WebPart webPart in manager.WebParts)
{
string type name="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
Type type = webPart.GetType();
if (type.FullName.Contains("ContentByQueryWebPart")
{
//then it is ContentByQueryWebPart
}
}
Friday, August 19, 2011
Unable to open SharePoint site on host machine
Few weeks back, i created one SharePoint site means a web application using Central Admin. One thing which i did different from usual is Host hearder entry. After creating site i tried to open it using host header or say fully qualified name but i couldn't open it on my local machine but though i can open it from other machines.
Also one more problem i was facing at the time of creating new SharPoint project from Visual Studio 2010. Error like below
One of my friend gave me this useful link that i am sharing with you
http://support.microsoft.com/kb/896861
To create/open project in Visual Studio try to use host header URL not machine name or localhost.
Also one more problem i was facing at the time of creating new SharPoint project from Visual Studio 2010. Error like below
Cannot connect to SharePoint Site: http://<sitename>/. Make sure that this valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL Property of the project.
One of my friend gave me this useful link that i am sharing with you
http://support.microsoft.com/kb/896861
To create/open project in Visual Studio try to use host header URL not machine name or localhost.
Thursday, May 5, 2011
Sharepoint: User Type field in schema.xml
I was writting schema.xml for Custom List Template, there i need field of type User like below
I was setting value of ShowField property to Job Title which i was using in CAML query to filter out the users. I searched lot for ShowField values of User type but i coudn't found anything from MSDN, even not an expected results from google. I am very much habitual of seeing the View Source of the HTML pages so i see the page source of Task list's User column and i got all the values from that source. I think looking out HTML pages source is not a bad practice :)
Friday, April 22, 2011
Webpart Preview Page: Event handler not firing in webpart
Today i faced realy strange issue with button event handler in webpart, my webpart created from SharePoint webpart class. This is code
public class MyFirstWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{
Label userName = new Label();
Button button;
protected override void CreateChildControls()
{
button = new Button();
userName.Text = "Sandip";
button.Text = "Change this text";
button.Click+=new EventHandler(button _Click);
this.Controls.Add(userName);
this.Controls.Add(button);
}
protected void button _Click(object sender, EventArgs e)
{
userName.Text = "Sandip Patil";
}
}
I wired up event handler in CreateChildControls method so that was not an issue. Issue is with testing webpart on the page. I was testing webpart on webpart preview page. You can find webpart preview page whenever you select any webpart from webpart gallery page. After 1 hour of wasting time, i created one webpart page and put that webpart inside webpart zone. Thereafter i could see that event handler was firing. Means problem was not with the code but with testing scenario.
Be careful when you test webpart on Webpart Preview page.Good Bye, Have a nice time...!
Friday, March 11, 2011
What is new in Visual Studio 2010 for SharePoint Developer?
Many of us are curious about new features of VS 2010 for SharePoint, Microsoft has provided good articles about this on their official site but we couldn't find this easily because keywords are not well defined for this entries.
First checkout the informational
What's New in SharePoint Development
then watch below video
Visual Studio 2010 for SharePoint 2010 Development
Enjoy SharePointing...!
First checkout the informational
What's New in SharePoint Development
then watch below video
Visual Studio 2010 for SharePoint 2010 Development
Enjoy SharePointing...!
Subscribe to:
Posts (Atom)