Visual Studio during Debugging: The function evaluation requires all threads to run

the function evaluation requires all threads to run visual studio 2019
model the function evaluation requires all threads to run
error = unable to evaluate the expression. operation not supported. unknown error: 0x80070057.
unable to find thread for evaluation
{implicit function evaluation is turned off by the user}
to prevent an unsafe abort when evaluating the function all threads were allowed to run
evaluate icon visual studio

I'm getting suddenly a strange error while debugging. Up to now the variable in the watch windows has been shown correctly. Now I am getting always the error message in the watch windows:

The function evaluation requires all threads to run

I am not able to check any variable anymore. I am not explicit working with threads. What can I do to get it working again?

I disabled already as mentioned in some forums the function: "Enable property Evaluation and other implicit function Calls" in the option window of the debugger. But without success, then I am getting the error:

Error Implicit Function evaluation disabled by the user

From the msdn forum:

This isn't an error in and of itself, but more of a feature of your debugger. Some properties require code to be executed in order for the property to be read, but if this requires cross-thread interaction, then other threads may have to run as well. The debugger doesn't do this automatically, but certainly can, with your permission. Just click the little evaluate icon and it will run your code and evaluate the property.

For further details on this behaviour check this excelent article

The function evaluation requires all threads to run, Visual Studio error message, "The function evaluation requires all threads to This is not an error message , this is just a hint of visual studio debugger. You could let vs to run the code in these threads and get the value. Visual Studio during Debugging: The function evaluation requires all threads to run Function to validate name for numbers and special characters Follow Bug Fixes & Coding Solutions on WordPress.com

I ran into this issue when just trying to get items from a table called "AGENCY" using Entity Framework:

var agencies = db.AGENCY.OrderBy(e => e.FULLNAME);

Hovering over agencies in debug mode, clicking to expand the options, and clicking Results would give the dreaded "The function evaluation requires all threads to run" with a "Do Not Enter" icon at the end that, on which, clicking did nothing.

2 possible solutions:

  1. Add .ToList() at the end:

    var agencies = db.AGENCY_TABLE.OrderBy(e => e.FULLNAME).ToList();

    List<AGENCY_TABLE> agencies = db.AGENCY_TABLE.OrderBy(e => e.FULLNAME).ToList();

    Credit goes to Hp93 for helping me come to this solution. In the comments on MUG4N's answer where I found this solution, it also mentions trying .Any() instead of .ToList(), but this gives a Boolean instead of a <T>, like <AGENCY> is, so it probably wouldn't help.

  2. Workaround - try a different path in the debug options. I found that I could click on the "Non-Public Members" > "_internalQuery" > ObjectQuery > Results View and get my values that way.

Why do we get “The function evaluation requires all threads to run , Please try again later. Published on Dec 7, 2016. Visual Studio during Debugging: The Duration: 0:52 Posted: Dec 7, 2016 Visual Studio during Debugging: The function evaluation requires all threads to run.

MUG4N has indeed provided a correct answer however if you hover over the line of code in debug, you may be looking at something like the below. If so, click the little re-evaluate icon highlighted in the image below...

NB: I obtained this image by pinning, normally the re-evaluate icone are in the middle of the window and not down the left hand column.

Solved: The function evaluation requires all threads to run, "The function evaluation requires all threads to run." message in Debugger or Quick Watch. Modified on: Wed, 18 Oct, 2017 Visual Studio hangs and seems to be waiting for something. For example, setting a breakpoint after obtaining a  Hovering over agencies in debug mode, clicking to expand the options, and clicking Results would give the dreaded "The function evaluation requires all threads to run" with a "Do Not Enter" icon at the end that, on which, clicking did nothing. 2 possible solutions: Add .ToList() at the end:

I use the next workaround to pass:

var OtherThreadField = "";
Invoke(new MethodInvoker(delegate
                    {
                        OtherThreadField = ExecuteNeededMEthod();
                    }));

Now i have a value for OtherThreadField.

"The function evaluation requires all threads to run." message in , list Items, but I'm getting The function evaluation requires all threads to run. MyContent>(); foreach (var uContent in UContentList) { var SContent = new IMyProgram. I think you're just having problems with debugging. Some properties require code to be executed in order for the property to be read, but if this requires cross-thread interaction, then other threads may have to run as well. The debugger doesn't do this automatically, but certainly can, with your permission. Just click the little evaluate icon and it will run your code and evaluate the property.

You should make thread safe call because accessing Windows form controls are not Thread safe in multithreading. This is my simple code which makes Thread safe call and sets Progress bar.

public partial class Form1 : Form
{// This delegate enables asynchronous calls for setting  
    // the text property on a TextBox control.  
    delegate void StringArgReturningVoidDelegate(string text);
    private Thread demoThread = null;

    public int Progresscount = 0;
    static EventWaitHandle waithandler = new AutoResetEvent(false);
    public Form1()
    {
        InitializeComponent();
    }
    public static bool CheckForInternetConnection()
    {
        try
        {


            using (var client = new WebClient())
            {
                using (var stream = client.OpenRead("http://www.google.com"))
                {
                    return true;
                }
            }
        }
        catch
        {
            return false;
        }
    }

    public  void Progressincrement()
    {

        waithandler.WaitOne();
        while (CheckForInternetConnection()==true)
        {
            if (Progresscount==100)

            {
                break;
            }
            SetLabel("Connected");
            Progresscount += 1;

       SetProgress(Progresscount.ToString());
            Thread.Sleep(TimeSpan.FromSeconds(1));
        }
        if (Progresscount <100)
        {
            Startthread();
        }
        SetLabel("Completed");


    }

  public  void Startthread ()
        {

   this.demoThread=   new Thread(new ThreadStart(Progressincrement));
        this.demoThread.Start();
     SetLabel("Waiting for connection");
        while (CheckForInternetConnection() == false) ;

        waithandler.Set();
    }
    private void SetLabel(string text)
    {
        // InvokeRequired required compares the thread ID of the  
        // calling thread to the thread ID of the creating thread.  
        // If these threads are different, it returns true.  
        if (this.label1.InvokeRequired)
        {
            StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetLabel);
            this.Invoke(d, new object[] { text });
        }
        else
        {
            this.label1.Text = text;
        }
    }
    private void SetProgress(string Value)
    {
        // InvokeRequired required compares the thread ID of the  
        // calling thread to the thread ID of the creating thread.  
        // If these threads are different, it returns true.  
        if (this.progressBar1.InvokeRequired)
        {
            StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetProgress);
            this.Invoke(d, new object[] {Value});
        }
        else
        {
            this.progressBar1.Value = Convert.ToInt32(Value);
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        Startthread();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Responsive");
    }
}

For more information MSDN

MSDN, virtual List<T> :“The function evaluation requires all threads to run”. I am following the following Program.Main(String[] args) in f:\Dropbox\Projects\visual studio  Visual Studio hangs and seems to be waiting for something. For example, setting a breakpoint after obtaining a DOM element and then inspecting its properties results in VS hanging for minutes and then nothing really useful coming back. In the Quick Watch you can see "The function evaluation requires all threads to run."

the function evaluation requires all threads to run, HI All, Getting the below error in C#.Net using PI SDK error || The function evaluation requires all thread to run Code || piPtVals = Visual Studio Debug Error: To prevent an unsafe abort when evaluating the function *.toString all threads where allowed to run. This may have changed the state of the process and any breakpoints encountered have been skipped. This error shows up quite often, and after a while Visual Studio crashes.

The function evaluation requires all threads to run, 3 and Micosoft Visual Studio 2010. While debugging I get error "The function evaluation requires all threads to run." continuously. This happens  To avoid a deadlock (where the method will wait forever for a thread that won't run), Visual Studio kills any spawned threads. My suggestion is to move the call into the program, and use some other means to execute it.

Getting error, To display the Threads window in break mode or run mode While Visual Studio is in debug mode, select the Debug menu, point to Windows, and then select Threads. To display or hide a column In the toolbar at the top of the Threads window, select Columns.

Comments
  • To get that point of the list: Have you restarted Visual Studio?
  • Yes, I did. Restarted and same issue.
  • check this out: stackoverflow.com/questions/4280604/…
  • Even if it would work, this can't be the solution, as I want to use the NET 4.x Framework. I do not want to downgrade just because if this issue. I am wondering why it was working some time ago.
  • i have the same issue. VS2013 had a button you could click, but VS2015 does not have this button.
  • I did read this article. I have no such a button to click, So not exactly the issue i have. Strange enough is, that it was working since I have upgraded to Visual Studio 2015 RC today.
  • Even that small snipped is not working anymore, when trying to get the result value with help of the watch window. public IEnumerable<clsDefinitions.Mapping> MappingQuery() { var context = new DatabaseEntities(); context.Database.Connection.ConnectionString = GlobalData.ConnectionString; var Results = from a in context.Mapping select new clsDefinitions.Mapping { value1= a.value1, value2 = a.value2 }; return Results;
  • Same issue here: stackoverflow.com/questions/4460206/…
  • If you don't see any icon, try modify the variable/command to execute the query from the watch window, instead of using drop down to explore it's properties. For example, adding .ToList() or .Any().
  • I'm not sure why but calling .ToList() on my query fixed the issue