You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting back to the previous posting about capturing StdOut, I've got things going to the point where I can have stdout/stderr being either buffered and then displayed or pushed to RichEditBoxes [REBs] while the process that is putting stuff in stdout/stderr is running. But is that what is happening? It appears not.
(quietude controls whether the output is buffered or put into the REBs.)
AddError and AddOutput and their helper method are defined as
public void AddOutput(string text)
{
AddInsertParagraph(outputText, text, true, false);
}
public void AddError(string text)
{
AddInsertParagraph(errorText, text, true, false);
}
private static void AddInsertParagraph(RichEditBox reb, string text, bool addInsert = true, bool withPrefix = true)
{
if (string.IsNullOrEmpty(text))
{
return;
}
const string stamp = "> ";
if (withPrefix)
text = text.Insert(0, stamp);
reb.IsReadOnly = false;
reb.Document.GetText(Microsoft.UI.Text.TextGetOptions.UseLf, out string? t);
if (addInsert)
{
reb.Document.SetText(Microsoft.UI.Text.TextSetOptions.None, t + "\n" + text);
}
else
{
reb.Document.SetText(Microsoft.UI.Text.TextSetOptions.None, text + "\n" + t);
}
reb.IsReadOnly = true;
}
(I thought I saw in the documentation that one could write to the REBs even when .IsReadOnly was true but actually one gets a 0x80070005 - Attempted to perform an unauthorized operation, when writing to a read-only REB, thus the false-ing and true-ing.)
When I run this code the REBs fill only after the script has completed. It seems that the enqueuing is doing just that -- enqueuing -- and then waiting around until it's got some good reason to run the items in the queue.
What's going on here? Is it that I don't understand threading (very likely)?
The other thing I'm noticing is that the enqueued tasks don't run in any particular order, so the 23rd line in the output doesn't necessarily appear in the REB after the 22nd and before the 24th.
Back in the day, the process would run in a CMD window and send its output to the CMD window's stdout and not be captured. Instead the called program would create .out and .err files and these would be loaded into the REBs. So now we're trying to replicate that behaviour ... without much success.
ONE HOUR LATER
The REBs are being updated. But they're not actually showing the data. And no equivalent for Google Apps Script's SpreadsheetApp.flush() seems to exist
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Getting back to the previous posting about capturing StdOut, I've got things going to the point where I can have stdout/stderr being either buffered and then displayed or pushed to RichEditBoxes [REBs] while the process that is putting stuff in stdout/stderr is running. But is that what is happening? It appears not.
So first up I get a ref to the current thread.
I pass that in to the method that runs the external process, viz
(
quietude
controls whether the output is buffered or put into the REBs.)AddError
andAddOutput
and their helper method are defined as(I thought I saw in the documentation that one could write to the REBs even when
.IsReadOnly
was true but actually one gets a0x80070005 - Attempted to perform an unauthorized operation
, when writing to a read-only REB, thus the false-ing and true-ing.)When I run this code the REBs fill only after the script has completed. It seems that the enqueuing is doing just that -- enqueuing -- and then waiting around until it's got some good reason to run the items in the queue.
What's going on here? Is it that I don't understand threading (very likely)?
The other thing I'm noticing is that the enqueued tasks don't run in any particular order, so the 23rd line in the output doesn't necessarily appear in the REB after the 22nd and before the 24th.
Back in the day, the process would run in a CMD window and send its output to the CMD window's stdout and not be captured. Instead the called program would create
.out
and.err
files and these would be loaded into the REBs. So now we're trying to replicate that behaviour ... without much success.ONE HOUR LATER
The REBs are being updated. But they're not actually showing the data. And no equivalent for Google Apps Script's
SpreadsheetApp.flush()
seems to existBeta Was this translation helpful? Give feedback.
All reactions