|
When I run the following code in Release mode, it tells me line 11, which is one too high. When I run it in Debug mode, I get the correct line number 10. Why?
using System;
using System.Diagnostics;
namespace Debugging
{
class Program
{
static void Main(string[] args)
{
ShowDebugInfo();
Console.ReadKey();
}
private static void ShowDebugInfo()
{
StackFrame here = new StackFrame(1, true);
Console.WriteLine(here.GetMethod().Name);
Console.WriteLine(here.GetFileLineNumber().ToString());
}
}
}
|
|
|
|
|
No, I don't have a clue why it does that. According to the documentation info like line numbers should only be available in debug builds so maybe its just random nonsense.
Regards,
Rob Philpott.
|
|
|
|
|
It's by design, your code was optimized in Release build. Turn off optimization in Release, and it will work. (but then you pretty much have the same as Debug).
|
|
|
|
|
Hi all,
Any one please tell what is the use and advantage of DTO also give me some URL where i can learn how to use DTO, Connecting DTO with my table
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
What does this have to do with C#?
Please post your specific C# issue.
|
|
|
|
|
I want to get conditional formatting range if an excel sheet
for eg, if conditional formatting are set in an excel sheet in
cell range
a1 - b10
and
b25- c99
then , i want to get both this range and their corresponding conditional formatting condition , how can i get that
please help me
|
|
|
|
|
|
Hi,
I'm building a program which needs to load some data from a SQL server when it loads.
I've been trying to make a pretty loading screen while the program loads but have been running into a strange occurance.
Here is my code:
<br />
Thread loadingThread;<br />
loadingThread = new Thread(delegate()<br />
{<br />
Application.Run(new LoadingWindow()); <br />
});<br />
loadingThread.Start();<br />
<br />
Thread.Sleep(10000);
<br />
loadingThread.Abort();<br />
The code seems to work ok, except that when the loading thread is aborted the loading window doesn't disappear. When I run my mouse cursor over it (or click somewhere) however it does.
Does anyone know how I could fix this so that when the loading is completed, the loading window disappears correctly?
Cheers,
|
|
|
|
|
because u are not closing the form,
u can also use
this.BeginInvoke(" Delegate which loads your window");
'
'
Do some Stuff
'
'
'
'
'
this.BeginInvoke(" Delegate which close your window");
|
|
|
|
|
When you abort the thread, you kill the message pump that handles the messages that does everything in the GUI. There is nothing that can handle the message that says that the window should be removed.
Generally, using the Abort method is a bad way to stop a thread. The Abort method kills the thread by throwing a ThreadAbortException in it, which can happen anywhere in the thread's code. It's difficult to write code that can cope with that situation in a well behaved manner.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for you reply, I'm getting really stuck on this.
I've been trying to do what the guy above suggested with little success, here's where I'm at right now.
<br />
Form2 loadForm;<br />
<br />
private delegate void TestDelegate();<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
Thread t = new Thread(delegate() { <br />
this.loadForm = new Form2(); <br />
});<br />
t.Start();<br />
<br />
this.BeginInvoke(new TestDelegate(Openform));<br />
<br />
Thread.Sleep(4000);
<br />
this.BeginInvoke(new TestDelegate(Closeform));<br />
<br />
t.Abort();<br />
}<br />
<br />
private void Openform()<br />
{<br />
this.loadForm.ShowDialog();<br />
}<br />
<br />
private void Closeform()<br />
{<br />
this.loadForm.Dispose();<br />
}<br />
This isnt even compiling at moment (Error: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.), so I'm getting pretty anoyed with the whole threading thing.
How else can you close a thread without calling Abort? Can you spot where i'm screwing up here?
Im trying to:
1. Create a (non-visible) window in thread 1
2. Show a loading window in thread 2 (form 2)
3. Do some loading in thread 1
4. Close the loading window in thread 2
5. Show the window in thread 1
Thanks heaps,
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
private delegate void TestDelegate();
Form2 loadForm;
public Form1()
{
InitializeComponent();
loadForm = new loadForm();
Thread t=new Thread(start1);
t.Start();
}
private void Openform()
{
loadForm.ShowDialog();
}
private void Closeform()
{
loadForm.Dispose();
}
private void start1()
{
this.BeginInvoke(new TestDelegate(Openform));
Thread.Sleep(2000); // do stuff in main thread
this.BeginInvoke(new TestDelegate(Closeform));
}
}
}
//Try this one
|
|
|
|
|
Hey thanks for your help.
It works fine if i'm doing no loading after the thread start command, but if I add the PopulateTree call (or just a Thread.Sleep()), it gives me a InvalidOperationException (Invoke or BeginInvoke cannot be called on a control until the window handle has been created).
Here's what i've got:
<br />
public PALImporter()<br />
{<br />
this.loadWindow = new LoadingWindow();<br />
Thread loadingThread = new Thread(new ThreadStart(this.BeginLoad));<br />
loadingThread.Start();<br />
<br />
PopulateTree(new SqlCommand("SELECT * FROM Users", myConnection), (int)Tables.Users);<br />
}<br />
}<br />
<br />
private void BeginLoad()<br />
{<br />
this.BeginInvoke(new LoadDelegate(OpenLoadForm));<br />
<br />
Thread.Sleep(2000);<br />
<br />
this.BeginInvoke(new LoadDelegate(CloseLoadForm));<br />
}<br />
<br />
private void OpenLoadForm()<br />
{<br />
this.loadWindow.ShowDialog();<br />
}<br />
<br />
private void CloseLoadForm()<br />
{<br />
this.loadWindow.Dispose();<br />
}<br />
|
|
|
|
|
Nevermind,
I decided to flag the threading and just do it all on the one thread.
Cheers,
|
|
|
|
|
In DB having 2 different tables,
1 contain the Title/Heading for feild used in 2nd table.
For ex: 1 table contain Group Feild like Car, Bus etc
2nd table contain feild like car_model_1, car_Model_2, bus_model_1, bus_model_2 etc.......
From this 2nd table i need to put them in there belonging group.
Like searching and sorting the data, then using
-How many cars under Car group, bus in Bus group.
User is selecting car_model_1,car_model_n, bus_model_1 or any other option he wants, then i need to check every option & sort them according to there group.
Can any one fwd a link or some help.
Thanks & regards.
|
|
|
|
|
I think you need three relations in this case:
Relation 1:
Group (ID PK, Name)
-----
1, Car
2, Bus
3, Sportscar
4, Bike
...
Relation 2:
Model (ID PK, Name)
----
1, car_model_1
2, car_model_2
n, car_model_n
n+1, bus_model_1
n+m, bus_model_m
Relation 3:
ModelToGroup (Model FK, Group FK)
----
1, 1
2, 1
n, 1
n+1, 2
n+m, 2
...
According to what model the user selects, you can look which group this model belongs to and count the groups.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi all,
I have a customized treeview, now i want to add plus-minus sign in the node, its not happening when i have made ShowPlusMinus property true.can anybody help me to do that.
thanks in advance
|
|
|
|
|
By default it automatically gets added when your node contains a child node.
|
|
|
|
|
Hi Anurag,
thanks for your information. but i need to hide some default implemntation for eg. checkbox in parent node, for that i have used DrawDefault =false, so i want to draw the plusminus of my own. can you plz share some information regaridng this
Thanks in advance
|
|
|
|
|
Not sure it's possible in the standard Treeview. However Anurag is right, I add a dummy child to each node when doing on demand trees and then check the children on BeforeExpand event.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The last time I had that problem it was because I has set the BackColor to Black and hadn't changed the ForeColor.
|
|
|
|
|
Hi
you can use this code to add Prent and Child nodes and plus-minus sign in the node wilol be added
Dim node As TreeGridNode
node= TreeGridNode.add(Id,name) //For parent node
node.nodes.add(Id,name) // for Child node
Regards
|
|
|
|
|
Kid sister rule got to the title!
You don't have the combo boxes above the code page to access the controls and the methods in the current class . Or am I missing something. This is the most frustrating thing (and square brackets) in the change from VB to C#.
Got my DAL working, half way through the code gen app I had forgotten how much fun it is to be applying something new. I've been here too long, time to move on.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: You don't have the combo boxes above the code page to access the controls and the methods in the current class
I do. Don't remember turning it on. I'm sure they were there by default.
Simon
|
|
|
|
|
damn now I have to rat through all the menus and options to find when the switch is. Thanks for the info.
[got it] options text editor allow navigation bar!
Never underestimate the power of human stupidity
RAH
|
|
|
|