Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
D

d87c

@d87c
About
Posts
7
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • TaskFactory AutoResetEvent DeadLock on Window Service
    D d87c

    Hi all C# gurus I need advice on Deadlock I have a code structure for Window Service, multithreading, task factory like

    public partial class rs : ServiceBase
    {
    private Queue jobQueue = Queue.Synchronized(new Queue());
    private Queue DatafeedQueue = Queue.Synchronized(new Queue());
    private Dictionary<...> ScheduleJobs = new Dictionary<...>();
    private AutoResetEvent _BlockThreadTaskScheduler = new AutoResetEvent(true);
    private AutoResetEvent _BlockThreadDatafeedSourceTaskScheduler = new AutoResetEvent(false);
    private LimitedConcurrencyLevelTaskScheduler _TaskScheduler;
    private LimitedConcurrencyLevelTaskScheduler _DatafeedSourceTaskScheduler;

        public rs()
        {
    		InitializeComponent();
    		\_timer = new System.Timers.Timer(POLL\_INTERVAL\_MINUTE \* 60 \* 1000);
    		\_timer.Elapsed += new System.Timers.ElapsedEventHandler(\_timer\_Elapsed);
    		\_TaskScheduler = new LimitedConcurrencyLevelTaskScheduler(2);
    		\_DatafeedSourceTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(1);
      
    		protected void \_timer\_Elapsed(object sender, ElapsedEventArgs e)
    		{
    			try
    			{
    				DatafeedQueue.Clear();
    				try
    				{
    					(Execute a stored procedure here)
    					while(xxx.Read())
    					{
    						DatafeedObj dfo = new DatafeedObj();
    						...
    						DatafeedQueue.Enqueue(dfo);
    					}
    				}
    				catch()...
    			
    			TaskFactory DatafeedSourceFactory = new TaskFactory(\_DatafeedSourceTaskScheduler);
    			// DatafeedQueue.Count = 3
    			for (int i = 0; i < DatafeedQueue.Count; i++)
    			{
    				DatafeedSourceFactory.StartNew(() => processDatafeedQueue());
    			}
    
    			\_BlockThreadDatafeedSourceTaskScheduler.Set();
    
    			}
    			catch()...
    		}
    		private void processDatafeedQueue()
    		{
    			\_BlockThreadDatafeedSourceTaskScheduler.WaitOne();
    			try
    			{
    				lock (DatafeedQueue.SyncRoot)
    				{
    					if (DatafeedQueue.Count > 0)
    					{
    						DatafeedObj dfo = ((DatafeedObj)(DatafeedQueue.Dequeue()));
    						
    						#region DataFeed Type A
    						
    						ScheduleJobs = (Calls a static class, static method);
    						jobQueue = (Calls a static class, static method turn ScheduleJobs  dictionary into Queue);
    						var factory = new TaskFactory(\_TaskScheduler);
    						for (int i = 0; i < jobQueue.Count; i++)
    						{
    							factory.StartNew(() => startTypeA());
    						}
    						
    						#endregion
    						  
    						#region DataFeed Type B
    						
    						ScheduleJobs = (Calls a stat
    
    C# csharp database data-structures

  • C# MySQL Question
    D d87c

    my friend's db is mysql and I am trying to grab his data and then store the value into my sql db Im grabbing the mysql data parse into a collect list its a WCF project so I created a datamember of int newNumber ... thats why I need to grab it int newNumber = (int)(byte)reader["fieldName"]; doesn't work >< it looks like it is reading as a bool value cause if i convert it to a string, it will gives false since in that column, I have values of 0, 4, 6 ,7

    C# help question csharp mysql

  • C# MySQL Question
    D d87c

    I tried byte as well, still same error, specific cast .... =(

    C# help question csharp mysql

  • C# MySQL Question
    D d87c

    thank for your reply, however, I got an error and it says Specific Cast is not valid

    C# help question csharp mysql

  • C# MySQL Question
    D d87c

    Hi All, I have a problem I have a MySQL Table, one of the columns' Data Type is TinyInt(1) When I use this line of code it gives an error int newNumber = int.Parse(string.Format("{0}", reader["someField"])); I think the reader is reading a bool value however MySQL Table has row values of 0 & 1 & 6 & 7 so it is not bool true/false type How can I actually grab that value to store into "int newNumber" Thanks

    C# help question csharp mysql

  • Quick C# Help Retrieve data using while (!sr.EndOfStream)
    D d87c

    I figure it out, just iterate over the array and write out each one individually. But im actually stuck on the next step lol i hope you can help out too. static void Main(string[] args) { string[] meals = System.IO.File.ReadAllLines("meals.csv"); foreach (string meal in meals) Console.WriteLine(meal); Console.ReadKey(); } the price actually needed to times by 1.8 so Price = Cost * 1.8 also i'll be dealing with bubble sort.. which I have never learn to knew how to coz we have ot make it look like this in the end * Lunch Items * $15.46 bento box a - chicken teriyaki, box combo $17.26 bento box b – sashimi, box combo * Dinner Items * $7.11 roe, 2 rolls $8.10 tuna roll, 3 rolls $6.30 vegetable sushi, 6 rolls

    C# help csharp data-structures question

  • Quick C# Help Retrieve data using while (!sr.EndOfStream)
    D d87c

    I ran into problem for my school assignment and it is to display whatever in a meal.csv file, here is a code we are starting with. The array string of itemDetails is where the data is store then passed into array ReadLines, then in Main, it is passed to mealContent, but when I tried Console.WriteLine(mealContent); it only prompted System.String[]. So how do I at least display it out in the command prompt. Thanks for the help guys~ Source code is also attached Code/meal.csv lunch,bento box b - sashimi,box combo,$9.59 dinner,vegetable sushi,6 rolls,$3.50 dinner,tuna roll,3 rolls,$4.50 dinner,roe, 2 rolls,$3.95 lunch,bento box a - chicken teriyaki,box combo,$8.59 lunch,bento box b - sashimi,box combo,$9.59 dinner,vegetable sushi,6 rolls,$3.50 dinner,tuna roll,3 rolls,$4.50 dinner,roe, 2 rolls,$3.95 lunch,bento box a - chicken teriyaki,box combo,$8.59 FileIOManager/FileLocation.cs using System; namespace FileIOManager { static class FileLocation { public const string INPUT_FILE = "../../Data/meals.csv"; } } using System; namespace FileIOManager { static class FileLocation { public const string INPUT_FILE = "../../Data/meals.csv"; } } FileIOManager/FileReader.cs using System; using System.IO; namespace FileIOManager { static public class FileReader { private static int GetLineCount() { StreamReader sr = new StreamReader(FileLocation.INPUT_FILE); int counter = 0; while (!sr.EndOfStream) { counter++; sr.ReadLine(); } sr.Close(); return counter; } public static string[] ReadLines() { int totalItems = GetLineCount(); string[] itemDetails = new string[totalItems]; StreamReader sr = new StreamReader(FileLocation.INPUT_FILE); string itemDetail; int counter = 0; while (!sr.EndOfStream){ itemDetail = sr.ReadLine(); if (itemDetail.Trim() != "") itemDetails[counter++] = itemDetail; } sr.Close(); return itemDetails; } } } :((

    C# help csharp data-structures question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups