스레드에서 내 사용자 지정 메서드를 호출하고 싶었습니다. 상기 방법에각 루프마다 (Thread C# 사용) 메소드를 만들고 호출하는 방법은 무엇입니까?
public void LoopOverAllLists(String _webAndSiteXml)
{
try
{
XmlNode _nodelist = SharePoint.ListsGetListCollection();
foreach (System.Xml.XmlNode _item in _nodelist.ChildNodes)
{
string title = _item.Attributes["Title"].Value;
//check for hidden list
if (_item.Attributes["Hidden"].Value.ToLower() == "false")
{
switch (_item.Attributes["ServerTemplate"].Value)
{
//Check whether list is document library
case SharePoint.LIST_ID_DOCUMENT_LIBRARY:
case SharePoint.LIST_ID_XML_FORMS:
case SharePoint.Publishing_ID_Pages:
{
//Get all documents info
try
{
GetAllDocumentsInfo(_item, _webAndSiteXml);
}
catch
{
}
break;
}
//Check whether list is having attachment
case SharePoint.LIST_ID_GENERIC:
case SharePoint.LIST_ID_ANNOUNCEMENTS:
case SharePoint.LIST_ID_CONTACTS:
case SharePoint.LIST_ID_TASKS:
case SharePoint.LIST_ID_EVENTS:
case SharePoint.LIST_ID_CUSTOM_GRID:
case SharePoint.LIST_ID_MEETING_SERIES:
case SharePoint.LIST_ID_MEETING_AGENDA:
case SharePoint.LIST_ID_MEETING_ATTENDEES:
case SharePoint.LIST_ID_MEETING_DECISIONS:
case SharePoint.LIST_ID_MEETING_OBJECTIVES:
case SharePoint.LIST_ID_MEETING_TTB:
case SharePoint.LIST_ID_MEETING_WS_PAGES:
case SharePoint.LIST_ID_PORTAL_SITE_LIST:
{
//Get all list items info having attachment
try
{
GetAllListItemsInfoOnlyAttachments(_item, _webAndSiteXml);
}
catch
{
}
break;
}
default:
GetAllListItemsInfoOnlyAttachments(_item, _webAndSiteXml);
break;
}
// Get All the List Forms
try
{
GetAllListForms(title, _webAndSiteXml);
}
catch
{
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
는 "GetAllDocumentsInfo, GetAllListItemsInfoOnlyAttachments 및 GetAllListForms"인 세 가지 방법 I는 C#으로 나사를 사용하여이 함수를 호출 원했다.
감사 대신 다른 방법에 대한
GetAllDocumentsInfo(_item, _webAndSiteXml);
사용을
Task.Factory.StartNew(() => GetAllDocumentsInfo(_item, _webAndSiteXml));
반복이 패턴을 호출
Task.Factory에는 스레드에 참여하기위한 뮤텍스 또는 조인 키워드가 없습니다. –
어떻게이 함수를 .net framwork 3.5에서 사용할 수 있습니까? –
나는 그가 묻지 않았기 때문에 동기화 문제를 언급하지 않기로 결정했다. 그 사람도 그 문제를 해결할 필요가있을 것이라고 확신합니다. .NET 4의 Task 라이브러리는 아마도 그가 갈 필요가있는 곳으로 가져갈 수 있습니다. – kenwarner