Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9238355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:44:33+00:00 2026-06-18T07:44:33+00:00

I need help: I’ve a nested object with associated Thread: public class XNodeViewModel {

  • 0

I need help:
I’ve a nested object with associated Thread:

public class XNodeViewModel 
{
    private int id;
    private Thread workerThread;
    private bool _alivingThread;
    readonly ObservableCollection<XNodeViewModel> _children;

    private XNodeViewModel(...)
    {
        ...
        if (...)
        {
            workerThread = new Thread(DoWork) { IsBackground = true };
            workerThread.Start();
        }
    }
    public ObservableCollection<XNodeViewModel> Children
    {
        get { return _children; }
    }

    public int Level
    {
        get { return _xnode.Level; }
    }
    public Thread WorkerThread
    {
        get { return this.workerThread; }
    }
}

in wpf code behind i’ve a reference to this ViewModel and i want to get all threads obects associated.
I’m learning Linq and i know that there are Function SelectMany to flatten nested objects:
With a button i want to stop all threads with this function:

public void StopAllThread()
{
    //_firstGeneration is my root object
    var threads = _firstGeneration.SelectMany(x => x.WorkerThread).ToList();
    foreach( thread in threads){
        workerThread.Abort();
    }
}

But the compiler tell me:

Error 1 The type arguments for method ‘System.Linq.Enumerable.SelectMany(System.Collections.Generic.IEnumerable, System.Func>)’ cannot be inferred from the usage. Try specifying the type arguments explicitly.

Only if i request type “Thread”.(if i’m requesting another type of object is ok)
where am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:44:34+00:00Added an answer on June 18, 2026 at 7:44 am

    You need to use Select instead of SelectMany:

    var threads = _firstGeneration.Select(x => x.WorkerThread);
    foreach(thread in threads)
        workerThread.Abort();
    

    SelectMany is used to flatten a list of lists. Your WorkerThread property doesn’t return a list, so SelectMany is the wrong method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help with one thing. I have DataGrid , binding it to this class:
Need Help in converting this to VB.NET public void GetCustomers(Action<IEnumerable<Customer>> onSuccess, Action<Exception> onFail) {
Need help speeding up a stored procedure ALTER PROCEDURE [dbo].[yearlynetsales] ( @YearToGet int, @current
Need Help - I have some code for Logout like this public void logoutFromFacebook()
Need help writing a regular expression to match any class containing the phrase block-container
Need help with implementing a pure abstract class via inheritance , using namespace to
Need help, function getFamily() { FB.api('/me/family', function(response) { alert(JSON.stringify(response)); }); } With the above
Need help with a query that I wrote: I have three tables Company id
Need help getting Ember-Data working with Zend Rest. At first, I'm familiar with Zend
Need help on these 2 questions: If i am tracking a virtual pageview for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.