ok. thanks for the help.
Original Message:
Sent: 03-07-2023 07:36
From: John
Subject: C# app wiht datalinq method for Xpression
async/await does not handle errors. It just lets your program to do stuff in the background, allowing the main program to keep going. It's probably not even necessary here since writing to a file should not take much time. If you want to handle errors, you need use exception handling.
try{ File.WriteAllText(@"D:\path.json", JsonSerializer.Serialize(_data));}catch (Exception e){ // If this code is reached, an error has occurred.}
------------------------------
JohnCorigliano
Senior Software Engineer
ISC
Original Message:
Sent: 03-06-2023 13:28
From: Rajimon
Subject: C# app wiht datalinq method for Xpression
I'm glad you brought that up. I think I'm going to give that a try with json. I found this post on stackoverflow, and maybe you can give me some advice here. I thought it might be a good idea to use the following technique to avoid locking up my app while serializing/reading/writing the file. Still, I'm thinking that the IOException could be the problem I'm worried about from Datalinq reading while I'm trying to write. Do I need to be concerned about this or will "await" avoid this exception?
using System.Text.Json;using System.Text.Json.Serialization;List<data> _data = new List<data>();_data.Add(new data(){ Id = 1, SSN = 2, Message = "A Message"});await using FileStream createStream = File.Create(@"D:\path.json");await JsonSerializer.SerializeAsync(createStream, _data);
------------------------------
Roger Heyward
Original Message:
Sent: 03-03-2023 10:25
From: John
Subject: C# app wiht datalinq method for Xpression
We've been using this method for a few years now - except we write JSON files, not XML, but the principal is the same. We write to these files as often as once every 10 seconds (occasionally faster) and collisions with Datalinq reading the file as we are writing them are rare. In the event of a collision, we just wait 1 second and try again and repeat this x number of times.
We are currently visiting the idea of changing the way we do things because of some issues we have had with Datalinq. Nothing major, Datalinq works fine, but we are now considering writing the data directly to the fields on the graphics to give us more control over things.
There are pros and cons to each method, so you will probably have to compromise at some point.
------------------------------
JohnCorigliano
Senior Software Engineer
ISC
Original Message:
Sent: 03-02-2023 09:06
From: Rajimon
Subject: C# app wiht datalinq method for Xpression
I'm thinking about making a C# app to replace my Dashboard. I've watched the Write a C Sharp or Visual Basic App XpressionU video. This video shows some great functionality, and I'd love to use C# instead of Dashboard, mostly because I think it is easier and has much more capability. HOWEVER, I can't decide what would be the best way to simulate how Dashboard shares all of the Parameters through an XML file. I suppose I could just write an XML file from my app anytime something changes that I could need in Xpression. Would this be my best bet, or should I consider a different way? The only thing I could image that could be problematic with this method is that I think I could run into file sharing issues. For example, might I have issues if Datalinq is reading the XML file while I'm trying to write the file in C#? I'm not sure how Dahsboard does it, but I'm just brainstorming before I go to far down the rabbit hole. Any thoughts?
------------------------------
Roger Heyward
------------------------------