How to get id stream in C #

public bool HasItemsFromPropertySet(InfoItemPropertySet propertySet, CompositeInfoItem itemRemoved)
    {
        var itemAndSubItems = new InfoItemCollection();
        if (itemRemoved != null)
        {
            itemAndSubItems.Add(itemRemoved);
            //foreach (InfoItem item in itemRemoved.AllDescendants)
            itemAndSubItems.AddRange(itemRemoved.AllDescendants);
        }
        return AllItems.AsParallel().Any(item => item.PropertySet == propertySet && !itemAndSubItems.Contains(item));
    }


In my code I use AsParallel (). Any () How can I get the thread id of the thread created by this AsParellel.Any () ...

+5
source share
1 answer

Thread.CurrentThread.ManagedThreadId gets the identifier of the managed thread of the current executable thread.

If you want to get your own thread identifier (not what you usually want to do), you can call the AppDomain.GetCurrentThreadId()(obsoleted " method , because it does not provide a stable identifier when managed flows are executed on fibers, but as far as I know, managed flows are only executed on fibers inside SQL Server).

+11
source

All Articles