|
Don't inherit the Bitmap, encapsulate it. Make a class that holds the Bitmap in a variable, and synchronises SetPixel calls on it.
Another alternative is to have a result queue, where the threads put their results, which the main thread then can read and put in a Bitmap. (It would have to be synchronised, of course, just like the task queue.)
It sounds like a lot of overhead to queue single pixels, though. You should consider handling blocks or lines of pixels.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Encapsulating the Bitmap doesn't help... I found that it will still throw exceptions in that case (object is in use by another thread).
But I DID solve the problem... I can create a Bitmap quickly from an array of bytes using Bitmaps LockBits and UnlockBits. I made a nice little class that I can access from multiple threads and that can quickly create a Bitmap.
SetPixel and GetPixel simply suck, as it turns out. They're too slow and cumbersome.
|
|
|
|
|
Shaamaan wrote: Encapsulating the Bitmap doesn't help... I found that it will still throw exceptions in that case (object is in use by another thread).
Then you only read half of what I wrote. Just encapsulating an object doesn't help a bit if you still allow unsynchronised access to it.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Hi.. this is a problem i've tried to figure out for a long time and i have searched google, MSDN, Businessobjects forums without any luck.
and i'm aware this might be offtopic but the project is written in C# and there's no crystalreport forum.
the problem is, i have a crystalreportviewer which shows a report with a group tree. if i click on a node on the group tree the viewer scrolls to the selected group. but only the header part of the group is scrolled into view. not the details, so the user would have to scroll down.
when i view the report in Crystal Reports 10 Professional. which was used to create the report,
it works fine, clicking on a group tree puts the group nicely at the top of the page so the underlying details are shown. we used to have an old OCX on a webpage. and that scrolled the whole group into view too. so i have ruled out the actual rpt file.
if i maximize the window and view the report in 80% this offcourse is no problem because i can see the whole page. but that's unfortunately not an option.
so does anyone know how to get the selected group to display at the top of the view?
If it' stuck, DO NOT pull harder!
|
|
|
|
|
hy everyone!
i do have a problem:
i do have a template which looks like that (just an example line)
tag1xxxx tag2xxxxxxxxx tag3xxxx tag4xxxxxxxxxxxxx tag5xxxxxxxx
the tag1, tag2 is the tagname i want to find in the output which should be replaced by it's value. the x afterwards is used for formating. this means tag1 has to be 8 char long, tag2 13 char etc.
so now i do want to replace tag1 for example with peter. peter is just 5 char long, so the last 3 x have to be replaced with spaces to keep the table with its format. but i can't just replace x by space because this would kill all the others.
my program should be something like
<br />
for (i=1; i<tags; i++)<br />
{<br />
Text.Replace("tag" + i, tagvalue);<br />
}<br />
examples / szenarios:
tag1xxxx tag2xxxxxxxxx tag3xxxx tag4xxxxxxxxxxxxx tag5xxxxxxxx
*) tagvalue1 < tag1 (tagname) => replace x by space and add spaces to the value before replacing the tagname tag1
*) tagvalue1 = tag1 (tagname) => replace x by space and replace the tagname tag1
*) tagvalue1 > tag1 (tagname) => remove length(tagvalue)-length(tagname) x and replace the remaining x by spaces and finally add the vale instead of the tagname.
do you have any good solution how to do this without a lot of lines? because this szenarios have to be placed in the loop described above.
thanks!
Stephan.
|
|
|
|
|
Hi .,
I have DataTable filled with the data. Now I want to change the
datatype of one of the column to sqldbtype.datetime .Is it possible to achieve?
Thanks
Navneet H
Develop2Program & Program2Develop
|
|
|
|
|
how to set the precision of double type in c#?
by default, 1/3=0.33333333333333, output from c#, If I want to the output is only 0.33, that means the output is only two number after the point.
thanks
|
|
|
|
|
double type makes round by defect. If you wan't round you have to use real...
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|
|
If it is just the display output you want :-
static void Main(string[] args)
{
double d = 1.0 / 3.0;
Console.WriteLine(d);
Console.WriteLine("{0:0.00}", d);
}</code>
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Hi,
Will i be able to use delegates in this code without inheriting the different classes.
If not what is the advantage in using delegates in this code?
Is delegate more useful when we are dealing with multiple forms and events?
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
public delegate void nameofdelegate();
class Program
{
public static void function1()
{
Console.WriteLine("will be called by the delegate");
Console.ReadLine();
}
}
class newprogram:Program
{
public static void function2()
{
Console.WriteLine("second delegate");
Console.ReadLine();
}
}
class mainprogram:newprogram
{
static void Main(string[] args)
{
nameofdelegate delobj = new nameofdelegate(function1);
nameofdelegate delobject = new nameofdelegate(function2);
delobj();
delobject();
}
}
}
Thanking you
k
|
|
|
|
|
new2pgrmg wrote: Will i be able to use delegates in this code without inheriting the different classes.
Yes. You just have to specify the class name to access the methods:
nameofdelegate delobj = new nameofdelegate(Program.function1);<br />
nameofdelegate delobject = new nameofdelegate(newProgram.function2);
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Thank You Sir that was very helpful.
Can you answer these also please
what is the advantage in using delegates in this code?
Is delegate more useful when we are dealing with multiple forms and events
Thanking You
k
|
|
|
|
|
new2pgrmg wrote: what is the advantage in using delegates in this code?
None.
Delegates are used when the method to call is not known when creating the code that will call it, or when the same code will be used to call different methods.
For example, you use a delegate when calling the List<T>.Find method:
List<int> list = new List<int>(new int[] { 1, 2, 3, 4, 5 } );<br />
int firstEven = list.Find(delegate(int x) { return x % 2 == 0; } );
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Hi all,
I want to overwrite an existing file (acttually, it's an excel file). But i don't know whether it's in use or locked by another process or not.
Is there a way to check that.
Thanks.
|
|
|
|
|
use a file which is locked u will get an exception
handle that exception using try catch block ...
Exception handling tat's all
|
|
|
|
|
If you're using the Excel PIAs then the _Workbook class has a ReadOnly property that's useful for determining if the file is a readonly file or if an instance of Excel already has the workbook open. Not sure if it can tell if it's locked by any other process, but it does know if it's locked by Excel.
|
|
|
|
|
Hi
this is my firs post on this board, hope I'll get some help.
I have an wpf application that can run in more then one instance.
I have another web service running in a web page in different app, to invoke method on the already running wpf app.
I can get the wpf processes running that no problem, but can't cast it to instance of an object in order to invoke object public methods.
Is that possible?
thanks in advance
Elad
|
|
|
|
|
Hi all,
I'm developing a simple application in which i need to play AVI with few options
The problems is i'm not getting how to play the avi from some particular frame, like i need to Play from Frame 7, i wont be able to do that but it starts from the initial frame.
Secondly, i need to extract snap to display where the particular subtitle is found. There isnt any function provided to capture the snap, other than invoking our own designed Snapper. Is there any alternate solution.
Hope, anyone among thousands, know such things.
Thanks
Determination and faith are the only keys !
|
|
|
|
|
Hello experts,
I create a desktop application using C#.net 2005. I also set right anchor and dock property of each control. And it works fine on different resolution and while resize the form in XP.
But what I saw the labels are mis-palced in vista. What is the problem...?
Regards
Pankaj Joshi
|
|
|
|
|
Did you ever find a solution to this?
Just found out that i have same issue like you had....
|
|
|
|
|
hello
i need to get different values from different tables but i have to show all in a grid...?
can yu help me?
self confidence+hard work=SUCCESS
|
|
|
|
|
Sorry to say but your question is too confusing. As I interprete it
you want to retrive data from multiple table and want to show in single grid OK?
For that you just write a join query and fill the dataset or datatable and attached it with the grid.
Regards
Pankaj Joshi
|
|
|
|
|
thanks pankaj
self confidence+hard work=SUCCESS
|
|
|
|
|
You just need to write a join query to fetch data... from different tables...
and if u don't want to write a join query and want to fetch data separately from different talbes.. then all the columns and columns type must be same in all the tables from which u want to fetch data
|
|
|
|
|
thanks bhatti
self confidence+hard work=SUCCESS
|
|
|
|