|
*grin* threading is always fun. And not in a good way. Congratulations
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Cheers fella ... its been a tad hairy already ... loads of testing to do to make sure It doesn't end up in thread hell!
I found this free ebook from jo Albahari really useful.
http://www.albahari.com/threading/[^]
I REALLY need to get a copy of his book - C# in a nutshell, total respect for the way he writes. So many techie books are written by people too close to the code if you get my meaning.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Jammer wrote: in the light of so many dumb questions from me lately
Tssk tssk. Don't diss yourself.
Jammer wrote: I thought in the light of so many dumb questions from me lately a bit of success should go reported as well ...
Congratulations - welcome to the world of the battle scarred.
|
|
|
|
|
Cheers fella ... much appreciated.
I'm sure it could be done better tho!
haha!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
BTW - did you get your LINQ SubmitChanges problem sorted?
|
|
|
|
|
Hi Pete,
Well sort of ... I'm still a bit confused about it to be honest.
Basically I think it has something to do with how LINQ and the immediate window interact. I was running a routine from the immediate window but each time it hit the SubmitChanges() line it would perform the submit and then just sit there waiting ... and waiting ... pressing pause stopped the debugging and left a green arrow saying that the submit line was the next due for execution. Hitting stop and going to have a look at the database showed the record in there that was added by the submit line that the debugger was saying it was about to execute ...
Really odd ... I haven't changed any code in that part of the app and running it via the interface is fine but even now if I run it via the immediate window I see the same behaviour ...
odd ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I'm trying to change data from one database .mdb file (MSAccess). Every time I want to add new item into database file, I click on button ADD. The first time, I tried to use CurrencyManager, the second time, I tried to use query. Then I closed my program and open my database file by MS Access program but I cannot see any change on it. Only database from the cache (when my program was working) was change.
This is my 2 codes. Any one can help me? 12pm already, I can not sleep with this!!!!
Thanks in advance!
CurrencyManager DBManager;<br />
OleDbConnection DBConnection;<br />
OleDbCommand DBCommand;<br />
OleDbDataAdapter DBAdapter;<br />
DataTable DBTable;<br />
string DBPath;
....<br />
DBPath = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " + openFileDialog1.FileName;<br />
DBConnection = new OleDbConnection(DBPath);<br />
DBConnection.Open();<br />
DBCommand = new OleDbCommand("Select * from handbook", DBConnection);<br />
DBAdapter = new OleDbDataAdapter();<br />
DBAdapter.SelectCommand = DBCommand;<br />
DBTable = new DataTable();<br />
DBAdapter.Fill(DBTable);<br />
txt1.DataBindings.Add("Text", DBTable, "ID");<br />
txt2.DataBindings.Add("Text", DBTable, "Serial");<br />
txt3.DataBindings.Add("Text", DBTable, "Comment");<br />
DBManager = CurrencyManager)BindingContext[DBTable];<br />
DBManager.RemoveAt(DBManager.Position);<br />
DBAdapter.Update();<br />
....
the second code:
private void button5_Click(object sender, EventArgs e)<br />
Add<br />
{<br />
DataSet dbSet;<br />
DataRow dbRow;<br />
<br />
<br />
dbRow = DBTable.NewRow();<br />
dbRow[1] = 5;<br />
dbRow[2] = "aaa";<br />
DBTable.Rows.Add(dbRow);<br />
DBTable = new DataTable();<br />
DBAdapter.Fill(DBTable);<br />
<br />
DBCommand = new OleDbCommand("insert into handbook (Serial, Comment) values (" + txt2.Text + ", " + txt3.Text + ")", DBConnection);<br />
DBAdapter.InsertCommand = DBCommand;<br />
<br />
DBAdapter.Update(DBTable);<br />
}
|
|
|
|
|
This is obviously just experimental code, it's not going to be used for anything ? Because otherwise you'd use real variable names and protect from SQL injection, right ?
Where is the DB that you're browsing to ? What if you look at it in access while your app is open ? I'm thinking it gets overwritten every time you run it in Visual Studio.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian,
I have found my basic mistake. Maybe working for a very long time made me so stupid...
Thanks so much for your reply, I've voted it 5 marks!
Best regards.
|
|
|
|
|
Hi guys, I have been searching alot but unluckily couldn't find anything. What i want is that to show nodes/bars around my custom button control so I can change its size through the mouse. Similiar like any other control when they are selected. Can somebody please help me out.
Thanks
|
|
|
|
|
This is in design mode ? Can't you just size it like any other control ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I want to do scaling for different kinds of custom controls that have their own paint methods. But still am not sure how can i display nodes so i can increase the size when i select the righ side node and move my mouse towards the right side direction. I don' want to type in the Size value.
|
|
|
|
|
When I create a custom control, and place it on a form, I can click on it, and then from there drag it to resize it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You are right if I have createad my user control and from the ToolBox Explorer in Visual studio i can drag and drop on my form.cs. I even see the selection box around the userControl. That's exactly what I want to show when i run my applicaion while i click on it. Is there anyway to turn on the designMode of the usercontrol when i run my app
That's how i am creating my userControl
public class Circle:UserControl
{
public Circle()
{
Size =new Size(100,100);
}
protected override void OnPaint(PaintEventArgs e)
{
//drawing circle here
}
}
|
|
|
|
|
OK, I see now. Your question was not clear. If you want the designer code at run time, you need to write the code to do it. Add hotspots, capture mouse clicks, resize your control and store it's size somewhere for when the app loads again
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for answering, but i am wondering is there any resource or link you can provide it. So atleast i would know how to start. Thanks
|
|
|
|
|
Hi there,
In my project I need to create a control in a form and edit it in a diferent thread, but as you all know, that is not possible because it is not allowed to edit something from another thread.
This way (i'm still learning how to use threads), I'm testing a simple project that will have 3 threads
1º- The Main Form
2º- A Count label that will be counting until 100
3º- A Count label that will be counting until 200
What am I trying to do?
- Create a Command that will receive the MainForm as a parameter (this way I can suspend, resume layouts and add Controls to it)
- Create in the Command constructor the label manually (exacly like the generated code from Designer) and the MethodInvoker. What I tried to do by doing so is to create the label, that I'm going to modify, IN the thread that is going to modify it.
- In the main form event of SHOWN call the constructor of the command and then the execute.
The code is at the end of this post.. i commented the line that crossthreads.
I tried creating the label Counter in the Designer but didn't work, then I tried to work around and do as shown above... but again.. I didn't think about the frmMain.Controls.Add(lblCounter) line that modifies the MainForm (in another Thread).
Well basecaly I'm having this problem for 2 reasons that differ from this article:
- The thread modify a Form/Control or something visual.
- The thread is a background process that counts until 100 (but I could let it count forever and it would never end... thats the problem...)
Anyone can help?
The Complete Command Code:
class UpdateCounterCmd: ICommand
{
private System.Windows.Forms.Label lblCount;
private Form1 frmMain;
private MethodInvoker delInvokeMe;
public UpdateCounterCmd(Form1 formMain)
{
lblCount = new System.Windows.Forms.Label();
frmMain = formMain;
delInvokeMe = new MethodInvoker(Count);
}
public void Execute()
{
delInvokeMe.BeginInvoke(CallBack, null);
}
private void CallBack(IAsyncResult ar)
{
delInvokeMe.EndInvoke(ar);
}
private void Count()
{
frmMain.SuspendLayout();
lblCounter.AutoSize = true;
lblCounter.Location = new System.Drawing.Point(333, 96);
lblCounter.Name = "LabelCount";
lblCounter.Size = new System.Drawing.Size(35, 13);
lblCounter.TabIndex = 0;
lblCounter.Text = "Counting: 0";
lblCounter.Visible = true;
frmMain.Controls.Add(lblCounter);
int i = 0;
for (i = 0; i <= 100; i++)
{
lblCounter.Text = "Counting: " + i.ToString();
frmMain.ResumeLayout(true);
frmMain.PerformLayout();
frmMain.SuspendLayout();
}
}
}
|
|
|
|
|
oscarderooij wrote: but I could let it count forever and it would never end... thats the problem...
Yeah, forever never ends. It might be a problem but you can't change it so learn to deal with it.
led mike
|
|
|
|
|
So you mean that I can't create a "background" thread that does something while the main program do the rest?
But that is not my question...
The question is how to modify a control created in another thread.
My project problem is:
I need to create a grid (Xceed GridControl) from a database query. But the query is HUUUUGEEE
so the program takes a huge amount of time to create the grid.
What I want is to create this grid for the main form in another thread so the main program can keep on going and creating different grids at the same time.
Any ideas?
|
|
|
|
|
oscarderooij wrote: So you mean that I can't create a "background" thread that does something while the main program do the rest?
No, that does not appear to be related in any way to what I said.
oscarderooij wrote: My project problem is:
I need to create a grid (Xceed GridControl) from a database query. But the query is HUUUUGEEE
so the program takes a huge amount of time to create the grid.
Well that certainly raises the question of why you didn't put that in your first post eh?
oscarderooij wrote: What I want is to create this grid for the main form in another thread so the main program can keep on going and creating different grids at the same time.
This is a common problem with junior developers. It's called "jumping to conclusions" and in science it's considered "bad".
The common practice solution to your problem is to implement Paging and possible Virtual Mode. If you use those key words in Google you will find much information on the subject. So a search phrase like: MSDN Grid Paging Virtual
Also the actual class name of the Grid control you are using might work better than "Grid" as a keyword.
led mike
|
|
|
|
|
Hi!
let's assume that the sproc returnes 20 rows.
well, i know that the sproc is going to be executed on the DB but
will Skip and Take do their stuff after the data (20 rows) from the sproc is returned to the application or will linq "do it's magic" and call converted to sql statements Skip and Take on the DB and return only 3 rows to the application?
thanks for any help
life is study!!!
|
|
|
|
|
Seishin# wrote: will linq "do it's magic"
Yes! Exactly! The definition of link in Websters just says "see magic". And if the link magic is not enough it will conjure the C# magic. If that is not enough C# will conjure C++ magic which will conjure C magic if needed which in turn, if needed, will conjure assembly magic.
Whew
led mike
|
|
|
|
|
c'mon.. I'm asking seriously..
by "do it's magic" I meant convert linq query into sql query, connect do DB, execute the query, return data and so on...
life is study!!!
|
|
|
|
|
Websters also says "post to linq forum"
It depends if it's a delayed query or not. If not, then it is done against and in-memory sequence
only two letters away from being an asset
|
|
|
|
|
ok.. who/what's "Websters"?!..
ou.. i didn't see linq mb..
sorry!!
life is study!!!
|
|
|
|