|
Rob Philpott wrote: should do the trick
Yes, it should.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Following Query will give you the result in a single string
SELECT [text] FROM sysobjects so INNER JOIN syscomments sc ON so.id = sc.id
WHERE [name] = '<sp name="">'
|
|
|
|
|
Hi,
I have set the timer1.enabled = true
and timer1.interval = 10000 --> represents 10 seconds
It seems the timer tick event does not get fired in windows service.
I have tried placing other timers and they seem to have the same issue.
When I use the timers on a form, they seem to work fine.
Question:
Is there anything I should do inside the windows service so that the tick event of the timer is fired?
Thanks
|
|
|
|
|
It works for me:
using System;
using System.Timers;
namespace ConsoleApplication2
{
internal class Program
{
private static void Main(string[] args)
{
Timer timer = new Timer();
timer.Interval = 10000;
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Enabled = true;
Console.Read();
}
private static void timer_Elapsed(object sender, ElapsedEventArgs e)
{
Console.WriteLine("Tick...!!!");
}
}
}
|
|
|
|
|
Do you use this in a windows service?
|
|
|
|
|
I am using a timer inside a Windows Service with no problem. I do use the Timer Start() and Stop() methods, but I would expect that enabling and disabling would work just fine. Have you checked the event viewer to ensure there are no errors being generated by the service that might explain this problem?
|
|
|
|
|
|
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.
|
|
|
|