Stock photo from pixabay.com

Simplest way to create a thread on SharePoint

This post describes the (probably) easiest and most straightforward way of creating a new Thread in your SharePoint (or any other .NET) server-side / desktop code.

Solution: how to create a new Thread

Let’s face it – one should not create new Threads lightly when developing SharePoint solutions, but sometimes it’s difficult to avoid. Or sometimes it’s just the simplest way to get around weird framework limitations.

 

This one time we were developing a pretty simple functionality, where we needed to create a few fields on a certain title when user activated a feature. However, because of the complexity of the environment, we encountered problems changing the title of the new field. Now, it’s usually pretty simple, but this time some other functionality, most likely developed by someone else, was changing it to the internal field name – which doesn’t look to good.

Thread thread = new Thread(delegate()
	{
		listFieldsUpdateSuccess = Helper.EnsureListFields(list);
		// rest omitted for clarity
	});

thread.IsBackground = true;
thread.Start();

To be honest, we’re not even sure, why this worked. We suspected it might be because of the current culture of the thread, but changing it didn’t have any effect. Any way, we’re glad this worked, whatever the reason for that is.

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff. This is his personal professional (e.g. professional, but definitely personal) blog.

1 thought on “Simplest way to create a thread on SharePoint

Let me know your thoughts!