|
Ista wrote: I even Tried AddRanges(secondList.Convert) and it didnt work
What is secondList.Convert? There's no need to convert it. Just firstList.AddRange(secondList).
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
That doesn't work. thanks tho
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
It does work, but only for C# 2.0 (as the AddRange method, not to mention the generic List<T> object, are both new additions to .NET 2.0). Are you using an older version?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Judah Himango wrote: It does work, but only for C# 2.0 (as the AddRange method, not to mention the generic List<t> object, are both new additions to .NET 2.0). Are you using an older version?
nope
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Ok then, that code works, compiles and runs just fine:
List<object> list1 = new List<object>();
List<object> list2 = new List<object>();
list1.AddRange(list2);
If that's not compiling for you, please give me the compiler error you're seeing.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I thank you for trying.
The problem was this:
<br />
The original as a List<Entry><br />
<br />
and I was returning a List<object><br />
and when calling AddRange the denominator must match.
So I need to call ConvertAll to fix the issue. ( transform the object to an Entry )
I do thank you for taking the time to help me with my issue.
Thanks,
Nick
-- modified at 15:38 Tuesday 15th August, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
That does work...try creating a console project and put this code into it.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<object> lstA = new List<object>();
List<object> lstB = new List<object>();
lstA.Add("a");
lstA.Add("b");
lstA.Add("c");
lstA.Add("d");
lstB.Add("e");
lstB.Add("f");
lstB.Add("g");
lstB.Add("h");
lstA.AddRange(lstB);
foreach (string s in lstA)
{
Console.WriteLine(s);
}
Console.ReadLine();
}
}
}
It provides the following output:
a
b
c
d
e
f
g
h
So, it would seem you've got other issues going on.
|
|
|
|
|
So I make this call:
__entries.AddRange(LoadEntries(typeof(Entry), parent.ID, parent)); // Entry is the class I create
which in turn calls this:
<br />
public List<object> LoadEntries(Type childType, int topicID, object topicParent) {<br />
<br />
List<object> returns = new List<object>();<br />
<br />
return returns;<br />
}<br />
And it gives me this error:
The best overloaded method match for 'System.Collections.Generic.List<t>.AddRange(System.Collections.Generic.IEnumerable<t>)' has some invalid arguments
-- modified at 11:24 Monday 14th August, 2006
-- modified at 11:25 Monday 14th August, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
I would use process of elimination to figure this problem out.
Replace the call to LoadEntries with something to the effect of:
new List<object>()
Or:
List<object> lstTemp = LoadEntries(typeof(Entry), parent.ID, parent);<br />
__entries.AddRange(lstTemp);
And see if that changes anything. The code I supplied works for the simple case and unless you've come across a compiler error (which is possible, but not very likely) it should work for this.
If not, keep trying to eliminate pieces of the code that might be causing the problem till you find something that works.
|
|
|
|
|
so I changed the code to be just
List<object> l = new List<object>(new ForumDAL.DALFactory().LoadEntries(typeof(T), Convert.ToInt32(prop.GetValue(__parent, null)), __parent));
__items.AddRange(l);
still doesn't work because GetEnumerator() does not work over Generic types.
Is there some way to convert it to just a standard Array type that supports IEnumerable in 1 line of code?
Here is the definietion if this helps
protected List<T> __items = new List<T>();
-- modified at 12:53 Monday 14th August, 2006
-- modified at 12:54 Monday 14th August, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Try using:
lstA.AddRange(lstB.ToArray());
What object type is the __items using? I hope its of object.
I would suggest not using the LoadEntries call at all to ensure what exactly the problem is. Separate your code into parts and try things you know work, until you find out what breaks it.
Good luck.
|
|
|
|
|
Andrew Rissing wrote: Try using:
lstA.AddRange(lstB.ToArray());
What object type is the __items using? I hope its of object.
I would suggest not using the LoadEntries call at all to ensure what exactly the problem is. Separate your code into parts and try things you know work, until you find out what breaks it.
Good luck.
Ok. I'm trying to remain relaxed on this one.
So, I did what you said and I have this:
List<object> bb = new List<object>();
__items.AddRange(bb);
Please pick this apart and say what I'm doing wrong.
Thanks,
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Nick,
I would double check that __items is of List<object>. What is the compiling error that you're getting?
I'm trying to help, but it just seems you've got something else going on here that is either really simple (mismatch on type, an overloaded class/method, etc.) or something out of your hands like a compiler issue.
|
|
|
|
|
public class ForumList<T> : IEnumerable {
protected List<T> __items = new List<T>();
... code ...
List<T> bb = new List<T>();
__items.AddRange(bb);
Okay so this worked.
but, if say i do this:
List<T> bb = new List<T>();
List<object> cc = new List<object>();
bb.AddRange(cc);
it wont work. It must be explictly created as type of "T". Is there a way through, maybe reflection, that I can add these dynamically?
The problem I have is that the LoadEntries has no knowledge of the Entry class the template value is. SO I would need to create it on the fly. Otherwise I get a circular reference issue.
-- modified at 15:52 Monday 14th August, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
You'll have to convert the list coming out of the function then to the proper type.
Try using ConvertAll on the List instance or perhaps by iterating over the list and type casting by hand. Either will do...
|
|
|
|
|
Hey, thanks for all your help. I think I have it working now.
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
hi friends, i am doing a project on windows media player using c#. i know how to play mp3 songs but i'm unable to make a mp3 songs playlist. can any one help me with code.
thank you.
-- modified at 11:04 Monday 14th August, 2006
|
|
|
|
|
Open up an WMP playlist file (.wpl) and see its format. You could easily output a compatible format using the XML writing classes contained in System.Xml namespace.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
hi Himango
I am doing a project on windows media player using c#. i know how to play mp3 songs but i'm unable to make a mp3 songs playlist. can you help me with code.
Thankyou.
madhav
|
|
|
|
|
Do you want to build an MP3 playlist for Windows Media Player? If so, all you have to do is look at the format of the .wpl file type. OPen up a .wpl file in a text editor, it's pretty straightforward; it's just an XML formatted document containing the path to the MP3s you want in the playlist.
Once you have that, you can use classes inside the XML namespace to write an XML document containing the MP3s. If you need help with how to create an XML document from code, I suggest you start a new thread.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
A.I added the Sln file which is present in the normal test command plugin directory.
File->new project->
Then add existing items ->testcommand.sln
Rt click on the windows explorer->build
1.Entry point not defined error.
|
|
|
|
|
|
Hi,
I have an application which gets info about system (for example running applications, processes, services, CPU info, OS info, ...). I create ProgressBar which will shows CPU usage (using WMI class to get actual usage). Then I create Timer (System.Windows.Forms.Timer) and set tick interval to one second. To get CPU usage and refresh ProgressBar to current usage value results to flicking in ListViews, when user wants to move with ScrollBar. Because of flicking I decided to create special thread for getting CPU usage and ProgressBar refresh to eliminate flicking. I create a new thread in constructor:
<br />
Thread threadRefresh = new Thread(new ThreadStart(Updating));<br />
threadRefresh.Start();<br />
which calls Updating method:
<br />
private void Updating() {<br />
refreshTimer.Tick += new EventHandler(RefreshCPUUsage);<br />
refreshTimer.Interval = 1000;<br />
refreshTimer.Start();<br />
}<br />
Method RefreshCPUUsage finally refresh ProgressBar:
<br />
private void RefreshCPUUsage(Object myObject, EventArgs myEventArgs) {<br />
manClass = new ManagementClass("Win32_PerfFormattedData_PerfOS_Processor");<br />
manObjectCollection = manClass.GetInstances();<br />
<br />
foreach (ManagementObject CPU in manObjectCollection) {<br />
progressBarCPU.Value = (int)Convert.ToUInt64(CPU.GetPropertyValue("PercentProcessorTime"));<br />
progressBarCPU.PerformStep();<br />
labelCPUPercent.Text = CPU.GetPropertyValue("PercentProcessorTime").ToString() + " %";<br />
}<br />
}<br />
This solution doesn't work, so I tried to do other based on System.Threading.Timer and Tread pool. In constructor:
<br />
WaitCallback myThreadMethod = new WaitCallback(Updating);<br />
ThreadPool.QueueUserWorkItem(myThreadMethod);<br />
Updating method:
<br />
private void Updating(Object stateInfo) {<br />
refreshTimer.Interval = 1000;<br />
refreshTimer.Elapsed += new ElapsedEventHandler(RefreshCPUUsage);<br />
refreshTimer.Start();<br />
}<br />
This is working but flickering in ListViews remains. I think that special thread for timer and refreshing can dispose flickering but it fails. Probably I'm doing somewhere mistake, but I don't know where. Please help me.
|
|
|
|
|
The problem isn't with the thread, its with the painting of the control.
You can problably set the DoubleBuffer property to true to alleviate this.
If it doesn't, then Look at your paint event.
Inside this event you probably have a method that is called that isnt returned immediately thus, cause the flicker.
Find a way to call it at some other point in time.
If your still stuck, then try exctending the List view and override the OnPaintBackground method. This redraws the control background. Warning tho. If you dont redraw the background you will see whats behind the control you dont paint that pixel.
The reason you see flicker is because of this>
The control calls OnPaintBackground. It then paints the control white or whatever the back color is
Then it calls your paint event. If the time it takes between the PaintBackground and end of the paint event. Then your eye perceives this as flicker.
Good luck
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
I have tried to use DoubleBuffer, but flickering remains. The area of ListView is not flickering but when Timer tick event occur and user is moving with scrollbar at that time, then scrollbar stops for a while and then continue in scrolling (lonely ListView is not redrawing or doing anything else). It seems that getting actual CPU usage info is demanding and because of that I tried to create special thread for timer and CPU usage info.
"Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."
|
|
|
|