|
We've run into a problem where we're getting a Task Canceled Exception. It seems to occur when
code inside a App.Current.Dispatcher.Invoke... gets executed AFTER App.Current.Shutdown is called.
I really don't want to have to check for the app being shutdown every time I do App.Current.Dispatcher.Invoke.
Any way to stop this?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
TaskCancelledException is what is thrown whenever one await a task which is cancelled.
In ContinueWith, however, the Task.Status is cancelled (no exception).
Some system task can, unexpectedly cancel. Find out which task are susceptible to be cancelled and handle the cancellation there. Otherwise it's a legitimate bug.
|
|
|
|
|
please explain that what is difference between LINQ and EF with example. thanks
tbhattacharjee
|
|
|
|
|
Seriously? I just read your question about what the difference is between Agile and Scrum. Have you heard of Google? You have been on this site long enough to know that you should at least think of doing some research beforehand yourself. This is a simple question for you to look up and I would strongly recommend that you learn to do the most basic searches yourself.
This space for rent
|
|
|
|
|
But that would mean doing his own homework...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
And stop being a help vampire? Might as well tell the sun to stop shining.
|
|
|
|
|
(Almost) the same as DML and DDL; ok?
|
|
|
|
|
|
How to generate ID with auto in my program using C# and Firebird database
|
|
|
|
|
Move to the DB forum
Then see this[^]
If it's not broken, fix it until it is
|
|
|
|
|
Try reading the documentation on Firebird. This has nothing to do with C#.
|
|
|
|
|
I asked a similar question a while back and never really got an answer, so I'll try again...
I have an application that has a component that works like DropBox. The user puts a file into a folder and it's copied to the server. Then all other users clients will download the file.
I need to determine the correct way of getting the file onto the server. The file will either be copied to the server or FTP'd in.
I need to determine when to use FTP. Obviously if the user is not connected to the network, then the file needs to be FTP'd in. For example, if the user takes their laptop home or on the road - away from the office - they they are not "connected" to the network and FTP needs to be used.
However, if the user is sitting at a desk in the office, then they are "connected" to the network.
The question is: How do I make the determination to FTP the file or just copy it? How can the app know if it's directly connected to the network?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
One way you could accomplish this would be to check the DNS resolution of the server. If it resolves to an internal address, then the client is local and would be capable of performing a direct copy.
You could also just simply try the copy, or a less intensive get directory listing using the file path in your application. If that fails, failover to ftp transfer.
Is ftp available both internally and externally? If so, it would probably be simpler to utilize it for both transfers. It seems to me that it really wouldn't matter how the file got to the server as long as it was on the server.
|
|
|
|
|
rhgarner wrote: One way you could accomplish this would be to check the DNS resolution of the server. If it resolves to an internal address, then the client is local and would be capable of performing a direct copy.
OK, how exactly?
rhgarner wrote: Is ftp available both internally and externally?
I thought of doing FTP either way, but internally it just seems like overkill.
If it's not broken, fix it until it is
|
|
|
|
|
Overkill is implementing more than one server and switching on detection of a network.
Just FTP it and you don't have to worry about the connection type at all.
Checking DNS resolution is probably not a good idea. DNS results are normally cached. Checking for active known company gateway addresses is probably a better bet, but if you just implement FTP, who cares?
|
|
|
|
|
Dave Kreskowiak wrote: f you just implement FTP, who cares?
I agree. I guess I'm just concerned about performance issues.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: How can the app know if it's directly connected to the network? How would you distinguish between the corporate network, and any other network?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thinking out loud, ip address range 10.b.c.d, 172.16.c.d, 192.168.c.d for instance and/or a dynamic dns check - Im pretty sure I could 99% of the time give a correct answer. I actually have software that checks the network interfaces in use from a PC and if it's the local wifi connection then 'probes' a set of addresses to see which MySQL server is up .. maybe the same approach would help Kevin
is that what were asking him Eddy ?
|
|
|
|
|
I have a web app where users can add any style property they want to the Style attribute of any DOM element on a web page.
The ID and the Style attributes of each DOM element are used to create a JSON array and sent to the backend to be converted into Dotnet objects. Then the deserialized data are used to create or update a CSS file.
I know that to convert JSON array objects to Dotnet objects, usually C# classes are created and properties are then created within those classes. Then the JSON array is deserialized using either JavascriptSerializer or JSON.Net which will populate the properties of the created classes.
The problem is I don't know ahead of time which properties of the Style attribute the user of my app will add to the JSON array.
modified 14-Sep-16 8:16am.
|
|
|
|
|
I can't help but think that a quick and dirty way to accomplish this would be to use a dynamic type to call JsonConvert.DeserializeObject (if you're using JSON.NET), and then use a little bit of reflection to pick out the public properties from here.
[Edit]
Thinking about this a bit further, it should be possible to use the JavaScriptSerializer like this:
Dictionary<string, object> values = new JavaScriptSerializer().DeserializeObject<string, object>(myJson);
This space for rent
modified 14-Sep-16 3:25am.
|
|
|
|
|
The in-build JSON functionality isn't great at these kinds of things. If you use a third party parser like Newtonsoft[^] it supports dynamic JSON better as it will build a collection of objects from the JSON that you can then traverse.
|
|
|
|
|
If you're using Newtonsoft Json.net, then you can get all the properties from the JSON objects something like the following:
JObject results = JObject.Parse(jsonString);
foreach (KeyValuePair<string, JToken> token in results) {
Console.WriteLine("object: token.Key");
foreach (JProperty prop in token.Value) {
Console.WriteLine("\t {0}:{1}", prop.Name, prop.Value);
}
}
|
|
|
|
|
Hi, below is my code snippet which uses the code you've provided. Although I'm not getting any errors, I'm also not getting anything at all.
string testString = string.Empty;
string jsonString = "{\"ID\": \"xx\", \"font-size\": \" 2em\",\"color\": \"blue\"}";
JObject result = JObject.Parse(jsonString);
foreach (KeyValuePair<string, JToken> token in result)
{
foreach (JProperty prop in token.Value)
{
testString = prop.Name + " : " + prop.Value;
}
}
modified 14-Sep-16 11:20am.
|
|
|
|
|
The reason for that is that you don't have a collective object. Normally, the JSON string would look something like:
string jsonString = "{theObject:{\"ID\": \"xx\", \"font-size\": \" 2em\",\"color\": \"blue\"}}";
Without the containing object, you will find your properties in the Key/Value pairs of the outer loop.
The way I got to all of this kind of stuff (I'm reading JSON from tmdb.org) was setting up this kind of test in a small console app, and using the debugger to step through and look at each of the JObject, JToken, and JProperty objects as it went through. I managed to get how it all holds together pretty quickly that way.
Cheers, and good luck.
Mick
|
|
|
|
|
Alternatively, if you don't have the containing object, parse the string directly into a JToken rather than the JObject.
Code under those circumstances would be:
tring testString = string.Empty;
string jsonString = "{\"ID\": \"xx\", \"font-size\": \" 2em\",\"color\": \"blue\"}";
JToken result = JObject.Parse(jsonString);
foreach (JProperty prop in result)
{
testString = prop.Name + " : " + prop.Value;
}
|
|
|
|