|
If you have access to an AOP system, it is probably worth decorating your method calls with pre and post logging to see which methods are being called and not returned from.
This space for rent
|
|
|
|
|
Mm.. thanks, that's an idea worth investigating!
|
|
|
|
|
Just a thought, but check through your property setters. You are looking for instances where the setter uses the property name in place of the member. Something like this
private int myInt;
public int MyInt
{
set { MyInt=value; }
}
This space for rent
|
|
|
|
|
I thought about it...
It's just, it's a lot of code to review for a shot in the dark... damn VS let me down there!
|
|
|
|
|
H, Lloyd,Quote: but which code? that is exactly my question? Knowing you to be an advanced programmer capable of impressive work, like your serializer, I think you must have some ideas about where in the code the recursion, or whatever, occurs.
Could you a counter-incrementing snippet in those places, and, when some reasonable limit was reached, hit a break=point ?
Sorry for the vagueness of all this, but, without a detailed over-view of the code ... it's all I got
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Thanks Bill!
Yea that was my thought and wrote such a utility / debugging helper method!
But then I thought, damn, being a shot in the dark I have to put in so many places...
I was thinking about it today (from the comfort of my home..) and.. I hardly can think of any place with recursion in the code...
|
|
|
|
|
Give your threads a name when creating one. It makes debugging a whole lot easier
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
It's so 2000 and late!
Now with Task madness, that doesn't work so well!
|
|
|
|
|
Sure it works. Windows hasn't been changed that much.
static class Program
{
[STAThread]
static void Main()
{
Thread.CurrentThread.Name = String.Format("Main UI thread for", Application.ProductName);
Task BackgroundJsonLoader = Task.Factory.StartNew(() =>
{
Thread.CurrentThread.Name = "BackgroundJsonLoader_C71B0546796D46A894925EAF6A0CF420";
Debug.WriteLine(Thread.CurrentThread.Name);
Debugger.Break();
});
When the debugger breaks, go the menu and select from "Debug" the submenu "Windows", the item "Threads" (Ctrl-D, T). You'll now have a list of all active threads. The named ones were created by you, in code. That gives us not just the advantage that we now can identify any thread or task by name, we can also see whether we spawned it or some third-party library.
Very easy to do, rarely ever done. The reason I added a GUID in there is to locate it quickly, as it is always my first line of code on the start of each thread or task.
--Downloading 2017 Community Edition now, will try it on a UWP app once the download is done
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
modified 28-Apr-18 7:28am.
|
|
|
|
|
That's worth writing up as a Tip.
|
|
|
|
|
Thanks! I'll post a cleaned up version later today then
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
what about
await Task.Delay(100)
Boom thread name lost!
modified 28-Apr-18 11:34am.
|
|
|
|
|
Add an exception-handler to your task; they don't dissappear into thin air without notice, unless you allow them to.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I do. TO all.
StackOverflow is uncatchable, at least in UWP. Sorry if that wasn't clear in my message, I thought the fact that Visual Studio debugger just CANT stop and break on them would have been enough of an indication....
|
|
|
|
|
Upvoted: that kind of advice is "worth its weight in gold" !
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Can anyone volunteer a 3D printer that does marble or granite stones to print the post for Bill?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
sadly it is useless advice...
Just checked this barely modified samples... does not work,...
Task.Factory.StartNew(async () =>
{
Thread.CurrentThread.Name = "BackgroundJsonLoader_C71B0546796D46A894925EAF6A0CF420";
Debug.WriteLine(Thread.CurrentThread.Name);
await Task.Delay(10);
Debug.WriteLine(Thread.CurrentThread.Name);
}).Wait();
In fact.. this snippet will be more instructive:
Task.Run(async () =>
{
Console.WriteLine("ThreadID: " +Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
await Task.Delay(10);
Console.WriteLine("ThreadID: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
}).Wait();
modified 28-Apr-18 11:54am.
|
|
|
|
|
Sadly this is a poor,misleading and contrived usage of Task.
In task heavy code that won't work, for the simple reason that as soon as and every time one write await the next line is, potentially, on another thread...
i.e. check that out
Task.Factory.StartNew(async () =>
{
Thread.CurrentThread.Name = "BackgroundJsonLoader_C71B0546796D46A894925EAF6A0CF420";
Debug.WriteLine(Thread.CurrentThread.Name);
await Task.Delay(10);
Debug.WriteLine(Thread.CurrentThread.Name);
});
In fact.. just try that and understand the magnitude of the problem (not my stackoverflow problem, mind you, the problem of tracking task as they go)
Task.Run(async () =>
{
Console.WriteLine("ThreadID: " +Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
await Task.Delay(10);
Console.WriteLine("ThreadID: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
}).Wait();
}
modified 28-Apr-18 11:53am.
|
|
|
|
|
Haha, yes, those new shortcuts to do async work are hiding some details. That's not a problem; you choose to write it like that
I don't see the example generating a stackoverflow though; that's more the territory of untamed recursion.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Yes indeed! Now you know!
Anyway, my problem is to stop on StackOverflowException...
News Flash: just did a small UWP test, and VisualStudio2017 did automatically break in the stack overflow exception I purposely generated...
Mmm.. strange, for some reason it doesn't do that at work. At least not on the exception crashing my work app.
|
|
|
|
|
Super Lloyd wrote: Anyway, my problem is to stop on StackOverflowException... Shouldn't be too hard; how many recursive methods are in your app?
Super Lloyd wrote: News Flash: just did a small UWP test, and VisualStudio2017 did automatically break in the stack overflow exception I purposely generated...
Mmm.. strange, for some reason it doesn't do that at work. Just a matter of counting; if you had a log that shows what is executed, you'd have a good start for a breakpoint.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi,
I need your help in my program. I am trying send data to remote server. I have made connection with remote server using TCP/IP it gives response now. But Now, i want to send command to server. it includes my first name, last name as FNAME, LNAME, EMAIL AND HOST-NAME and I am making this program for registration so after that server will return regstration number. when i try to send data it says, 530 command 'fname' command not accepted in this state. Now i don't understand how to bind all data in one string or what format should i use to send data so that i can send it to remote server. Thank you in advance.
Here is my code:
public void Connect(String server)
{
Int32 port = 123;
TcpClient client = new TcpClient(server, port);
string FNAME = "reet";
Byte[] data = System.Text.Encoding.ASCII.GetBytes(FNAME);
NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", FNAME);
data = new Byte[256];
String responseData = String.Empty;
Int32 bytes = stream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
stream.Close();
client.Close();
}
|
|
|
|
|
The server doesn't understand the data you're sending to it.
You need to consult the documentation for the server to find out what data and commands you need to send.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I know the commands these are FNAME, LNAME, EMAIL, HOST. In FNAME i will pass user first name in FNAME same for last name , email and host. or there is some way to send data to server that i don't know ?
|
|
|
|
|
No ... you did NOT send FNAME, LNAME or anything else remotely connected (pardon).
You sent: "reet".
Nothing more; nothing less.
Listen to the previous advice re: "commands" (and communication "protocols").
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|