|
PIEBALDconsult wrote: Why do you want to do it?
Possibly to allow existing processing to terminate cleanly, and prevent some new processing, while still running other background processing.
|
|
|
|
|
Electron Shepherd wrote: allow existing processing to terminate cleanly
Stop should do that as well.
Electron Shepherd wrote: while still running other background processing.
Then it's not paused, is it?
Electron Shepherd wrote: other background processing
Possibly should be in its own Service.
|
|
|
|
|
A good example would be a web server implementing Keep-Alive. You may need to prevent new inbound connections, possibly for load balancing or other resource allocation requirements, but preserve the internal state data.
Dont forget that just because you've never needed to do it doesn't mean no-one ever needs to do it.
|
|
|
|
|
Electron Shepherd wrote: A good example would be a web server implementing Keep-Alive. You may need to prevent new inbound connections, possibly for load balancing or other resource allocation requirements, but preserve the internal state data.
And you are suggesting that you would not do that when stopping as well?
Electron Shepherd wrote: Dont forget that just because you've never needed to do it doesn't mean no-one ever needs to do it.
Don't forget that just because someone wants to do something it means that it is a good idea. Or even that it will solve their real problem.
|
|
|
|
|
jschell wrote: And you are suggesting that you would not do that when stopping as well?
Yes, becuase in my specific example, the internal state is related to a TCP connection, so maintaining and restoring the state across a stop / start event is meaninglesss.
jschell wrote: Don't forget that just because someone wants to do something it means that it is a good idea.
True. My reply was directed at the person who said (very unhelpfully in my opinion)
"I haven't had a need to do that and I can't imagine needing it."
|
|
|
|
|
I believe ServiceBase has a property called CanPauseAndContinue . Set it to true and then override the OnPause and OnContinue methods.
|
|
|
|
|
Hi Calla,
that sounds good.
Thanks
Frank
|
|
|
|
|
You're welcome! 
|
|
|
|
|
Hi all developers.
Lately I started working on a library that allows to compose complex asynchronous operations from simple ones using LINQ syntax and extension methods. It can be found here. The idea itself was taken from F# asynchronous workflows, so I don't take any credit for the idea, just for the implementation.
The need occurred when I was working for a company that had an existing server that provided a known set of operations and we needed to write a UI client that the operations it wanted to perform were composition (sequential or parallel) of the server's operations. So instead of writing the ugly code with callbacks and exception handling we came up with this idea.
Here is a simple example for the library's usage:
Async<DataItem[]> operation =
from dataItems1 in provider1.AsyncGetDataItems("data items id")
from dataItems2 in provider2.AsyncGetDataItems(dataItems1)
select dataItems1.Concat(dataItems2).ToArray();
operation.Execute(CompletionCallback);
I would like you to try and and send me any feedback about the design/implementation and of course bug reports.
Thanks!
Alex.
P.S. I Googled it and found out that something already blogged about it. So other people came up with this idea too. I just didn't find a ready-to-use library that people can download and start using, so I decided to write one.
|
|
|
|
|
I want that check box in a datagridview should act like a radio button.Means whenever I select a checkbox it will be selected and rest of all would be deselect.
I have used cellContentClick event of the datagrid view.Structure of the datagridview is like-
1st column is checkbox and 2nd is text box.following is the code i have used-
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (i == e.RowIndex)
{
dataGridView1.Rows[i].Cells[0].Value = true;
}
else
{
dataGridView1.Rows[i].Cells[0].Value = false;
}
}
The above code runs good when i select another checkbox.But when one checkbox is selected/checked and now I again click on the same checkbox then it is deselected/unchecked.I want when the same checkbox is checked again it won't unchecked and remian checked.
How can I do this?
Thanks in adv....
|
|
|
|
|
If you must use checkboxes and not radiobuttons, then you could add something like the following to your call. You will of course want to add some better validation.
for( int i = 0; i < dataGridView1.Rows.Count; i++ )
{
CheckBox ctl = (CheckBox)dataGridView1.Rows[i].FindControl( "CheckBoxControlName" );
if( ctl != null )
{
ctl.Checked = ( i == e.RowIndex );
ctl.Enabled = !( i == e.RowIndex );
}
}
This would simply disable the currently selected checkbox while allowing any other to be selected.
(NOTE: I just hammered this out in the editor. If I have a syntax error or typo... sorry.)
modified on Wednesday, October 13, 2010 2:50 PM
|
|
|
|
|
You can do that by changing readonly property as below.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (i == e.RowIndex)
{
dataGridView1.Rows[i].Cells[0].Value = true;
dataGridView1.Rows[i].Cells[0].ReadOnly = true;
}
else
{
dataGridView1.Rows[i].Cells[0].Value = false;
dataGridView1.Rows[i].Cells[0].ReadOnly = false;
}
}
}
|
|
|
|
|
Hi.
I created a User Control.In load event it adds some text Boxes on it.
I built it and added its DLL to my toolbox.
1:I want to change those Text box on the User Control at design time after adding it on my form.
2:Or when i add this user control to my form,I want that the text boxes on User Control be added on my form(Form1).Is it possible to write such code???
Thank you.
CanI
|
|
|
|
|
|
hey guys.. i have a problem..actually i saw many document about it and i applied on my project but i couldnt solve it..i want to transfer datas btw two forms..for example i open Form2 with a button in Form1
and i want to get the text of the textbox in Form2 as a text of textbox in Form1
to do that i wrote that codes below but still i have nothing
here i opened Form2
private void btnRehber_Click(object sender, EventArgs e)
{
Form2 rhbForm = new Form2();
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
rhbForm.ShowDialog();
}
and here i filled the textboxes in Form2 and submit the values to the textboxes in Form1
private void btnEkle_Click(object sender, EventArgs e)
{
frmFirma = new Form1();
frmFirma.txtGsm1.Text = txtGsm1.Text;
frmFirma.txtGsm2.Text = txtGsm2.Text;
frmFirma.txtNumara.Text = txtNumara.Text;
}
do i make something wrong ? or is there another way ?
thanks guys for help
|
|
|
|
|
In Form1
public partial class Form1: Form
{
internal static string textboxdata = string.Emtpy;
public Form1()
{
InitializeComponent();
}
private void btnEkle_Click(object sender, EventArgs e)
{
textboxdata = txtGsm1.Text ;
}
}
in Form2 call this way
txtGsm1.Text = Form1.textboxdata ;
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Why suggest a static solution? Do you really think that is a good idea? If so, then perhaps you ought to re-read your C# books / lecture notes and brush up on basic OOP.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Look at your code.
See that keyword on the first line of each method?
The new keyword?
Now, what do you think that does?
1) Create a totally new variable, unconnected to any previous versions.
or
2) Access the correct old version of the variable that you had kicking around somewhere else in your program, but not to worry, the compiler will sort out which one your mean to use when it gets to it.
Now, do you see what is wrong?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
yeah i got what u mean..but what should i do instead of that ?
|
|
|
|
|
Use the existing instance.
private void btnRehber_Click(object sender, EventArgs e)
{
Form2 rhbForm = new Form2();
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
rhbForm.ShowDialog();
txtGsm1.Text = rhbForm.txtGsm1.Text;
txtGsm2.Text = rhbForm.txtGsm2.Text;
txtNumara.Text = rhbForm.txtNumara.Text;
}
Except that won't work as it is because the TextBoxes are (correctly) private to Form2. So instead add them as properties to Form2:
public class Form2 : Form
{
...
public string Gsm1
{
get { return txtGsm1.Text; }
}
...
} Reapeat for Gsm2 and Numara.
Then access Gsm1 in Form1:
private void btnRehber_Click(object sender, EventArgs e)
{
Form2 rhbForm = new Form2();
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
rhbForm.ShowDialog();
txtGsm1.Text = rhbForm.Gsm1;
txtGsm2.Text = rhbForm.Gsm2;
txtNumara.Text = rhbForm.Numara;
}
It would also be a good idea to make "yetkili" a property as well, this time with a setter as well as a getter.
The idea is that Form1 does not need to know how Form2 works - just that it can get Gsm data for it.
You can then change the internals of Form2 as much as you like, without having to alter Form1
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
thanks man
i did as i wished with your help and codes
really thank u so much )
|
|
|
|
|
It always amazes me that people try to write the most tortuous logic to communicate between two disparate items in an application when there are mechanisms built into the framework that allow you to do this with ease. Consider the problem if you want to do this with a modeless form; you want to one form to be able to respond to something that happened in another form; can you think of a mechanism that allows you to communicate in this fashion? I am, of course, talking about using events here.
Now, in your case, there is an even simpler way to achieve this. When you create an instance of Form2 (that's not a good name by the way, your naming convention should always indicate the intent of the item you are naming), you then display it using ShowDialog. This means that processing in Form1 halts until Form2 returns control to it - this, of course, means that you have access to the properties and methods inside Form2 until you Dispose of it. What you should do, in Form2, is create public properties that expose the values inside the textboxes and, once control has been returned to Form1, you should then take the values from it. Here's one way to code it:
private void btnRehber_Click(object sender, EventArgs e)
{
using (Form2 rhbForm = new Form2())
{
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
if (rhbForm.ShowDialog() == DialogResult.OK)
{
txtGsm1.Text = rhbForm.Gsm1;
txtGsm2.Text = rhbForm.Gsm2;
frmFirma.txtNumara.Text = rhbForm.Numara;
}
}
} Then, in Form2, I'd create Gsm1, Gsm2 and Numara as public (or internal) readonly properties which simply wrap access to the relevant textboxes.
|
|
|
|
|
hey friend i did changed my form names as u suggested... thanks for your suggestion..
|
|
|
|
|