|
|
While this approach could I'm sure be made to work I want to keep the general structure of what I'm doing since I'll be calculating other indicators not supported in SQL.
|
|
|
|
|
boreland wrote: calculating other indicators not supported in SQL
Such as? You stated you are calculating running averages, that indicates numeric data
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Could someone please advise if a transactional approach would be more efficient and if some how to do this using a datatable?
|
|
|
|
|
Your calculation of moving averages looks suspect. It looks like you're just adding the value from the nTh row to your "moving average", rather than the average of n rows...
You would likely get better performance and less memory consumption if you used a DataReader instead of a DataAdabtor and DataTables, and did your updates atomically as needed on a different connection using ExecuteNonQuery with an update statement instead of relying on a batch update...
|
|
|
|
|
They both appear to do the same thing to me, what should each one be used for and what one has a less performance hit?
Thanks!
|
|
|
|
|
Reading the documentation and, if important to you, performing a little experiment should provide the answer. Did you look at the values returned?
|
|
|
|
|
I am developing an add-in for VS for latex. The very first functionality I wish to implement is a button "compile" (to pdf). Well I can do that, but what I want is
1. Do not show a console window
2. Redirect text output (with errors/warnings/mesasges) from pdftex . The next step will be to parse these results and show them in a separate window.
I use the following code:
Document doc = _applicationObject.ActiveDocument;
if (Path.GetExtension(doc.Name) == ".tex")
{
var p = new System.Diagnostics.Process();
var pinfo =new ProcessStartInfo
{
CreateNoWindow = true,
FileName = "pdflatex",
Arguments = string.Format("\"{0}\" -c-style-errors", doc.FullName),
WorkingDirectory = Path.GetDirectoryName(doc.FullName),
};
p.EnableRaisingEvents = true;
p.Exited += p_Exited;
p.StartInfo = pinfo;
p.Start();
}
I have observed the following issues:
1. Uncommenting RedirectStandardError = true causes that pdftex does not work (no output file is generated at all)
If RedirectStandardError = true is commented, then pdftex does it's job. But:
2. Despite CreateNoWindow = true console still shows up.
3. p_Exited is never called
As you see none of things I wanted to do actually works. It is quite depressing. Any ideas?
Thanks--
Greetings - Jacek
|
|
|
|
|
Hi,
The exact behavior of a program is determined by the program itself; the StartInfo parameters only influence the way Windows simulates a user launching a process. If pdftex decides to open a console, there is nothing to stop it.
Didn't you forget to:
- set UseShellExecute false?
- also redirect standard output?
- addevent handlers or threads to actually read the output/error stream?
FYI: I just finished this article [^] on a related subject.
|
|
|
|
|
Luc Pattyn wrote: If pdftex decides to open a console, there is nothing to stop it
There are programs for LateX (like LyX), which use pdftex and no console is opened -- they show pdftex' output in some "output" window. So, it is possible to redirect the output.
Luc Pattyn wrote: Didn't you forget to: (etc.)
No, i did not forget.
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("err:" + e.Data);
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("out:" + e.Data);
}
void p_Exited(object sender, EventArgs e)
{...
I put breakpoints inside all these handlers, but they were never reached (breakpoints in other places work, so it is not a debugger problem).
I am close to giving up all this mess.
Greetings - Jacek
|
|
|
|
|
Jacek Gajek wrote: No, i did not forget.
That does not fit well with the code you have shown.
I'm afraid I can't provide any more help, unless you show actual code.
|
|
|
|
|
Luc Pattyn wrote: That does not fit well with the code you have shown.
I meant I hadn't forgotten to add apriopriate lines after reading your post, of course . Here is the full code.
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "LatexAddin.Connect.LatexAddin")
{
Document doc = _applicationObject.ActiveDocument;
if (Path.GetExtension(doc.Name) == ".tex")
{
var p = new System.Diagnostics.Process();
var pinfo =new ProcessStartInfo
{
WindowStyle=ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "pdflatex",
Arguments = string.Format("\"{0}\" -c-style-errors", doc.FullName),
WorkingDirectory = Path.GetDirectoryName(doc.FullName),
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false
};
p.StartInfo = pinfo;
p.OutputDataReceived += p_OutputDataReceived;
p.ErrorDataReceived += p_ErrorDataReceived;
p.EnableRaisingEvents = true;
p.Exited += p_Exited;
p.Start();
}
return;
}
}
}
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("out:" + e.Data);
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("out:" + e.Data);
}
void p_Exited(object sender, EventArgs e)
{
Console.Beep();
((Process) sender).Exited -= p_Exited;
((Process)sender).OutputDataReceived -= p_OutputDataReceived;
((Process)sender).ErrorDataReceived -= p_ErrorDataReceived;
}
Greetings - Jacek
|
|
|
|
|
For something like that that I'm playing with this week, I use:
this.process.StartInfo.CreateNoWindow = false ;
this.process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ; <-- may be unnecessary
this.process.StartInfo.UseShellExecute = false ;
this.process.StartInfo.RedirectStandardInput =
this.process.StartInfo.RedirectStandardOutput =
this.process.StartInfo.RedirectStandardError = true ;
this.process.Start() ;
And I don't use the events.
One of the problems[^] into which I ran is that reading from the error stream seems to block.
I now have a work-around for that, which I may submit in an article today.
|
|
|
|
|
Thanks.
PIEBALDconsult wrote: this.process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ; <-- may be unnecessary
This one did the trick.
Greetings - Jacek
|
|
|
|
|
Hurray it worked! thank you so much
Solution:
process.Start();
process.ErrorDataReceived+=new DataReceivedEventHandler(process_ErrorDataReceived);
process.OutputDataReceived+=new DataReceivedEventHandler(process_OutputDataReceived);
process.BeginOutputReadLine();
process.BeginErrorReadLine();
Greetings - Jacek
|
|
|
|
|
right. You did peek at my article?
|
|
|
|
|
Umm, yeach. Thank you both then.
Greetings - Jacek
|
|
|
|
|
you're welcome.
|
|
|
|
|
Some time ago, I had to do something similar (executing a command line tool from an ASP.NET application and parsing the result).
The following code worked for me:
ProcessStartInfo info = new ProcessStartInfo(executablePath)
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardOutput = true
};
|
|
|
|
|
Suppose i am writing code in .net e.g
int i=10
then .net show me red line under the code where error occurs.we know the i have not apply semicolon at the end of syntax(int i=10;)
who handles these error while writing the source code???.
|
|
|
|
|
Well, you do! I'm not going to come over there, press the ';' key for you and then go back home again, am I?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
if you are not able to under stand the query then pls never try to reply.
thanks for your suggestion.
|
|
|
|
|
It is your responsility to phrase the question correctly so other will understand you. If you can't do that and be civil, then please don't post here again.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sharma Dinesh Kumar wrote: who handles these error while writing the source code???.
It is the responsibility of the developer to correct such errors.
Is this your first time programming?
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Sharma Dinesh Kumar wrote: who handles these error while writing the source code???
I'm going to guess that you want to know how the computer "knows" how to read C#-sourcecode and where that spellingchecker-thingy is getting it's intelligence from to recognize a syntax-error.
This assumption correct?
I are Troll
|
|
|
|