Tags » Programming

Yahoo! Finance charts, unreliable

by,

One Frustrated American

When will Yahoo! ever get its act together again?  I mean, it’s been years now of messed up e-mail, finance, and news sections.   323 more words

What Do YOU Think?

Hello world!

This Webpage was made on WordPress. The reason for this is because of a certain amount of frugality while I do not have a job. The point of this page is to demonstrate a familiarity with web design and upkeep. 83 more words

CSS

C# - Simple example implementing concurrent queue

public class ActionQueueItem
{
    public ActionQueueItem(Action operation, string name, int priority)
    {
        Operation = operation;
        Delay = 500; // 500 milliseconds
        Name = name;
        Priority = priority;
    }

    public ActionQueueItem(Action operation, string name, int delay, int priority)
    {
        Operation = operation;
        Name = name;
        Delay = delay;
        Priority = priority;
    }

    public Action Operation { get; private set; }
    public int Delay { get; set; }
    public string Name { get; set; }
    public int Priority { get; set; }
}

public class ActionDelayQueue
{
    ManualResetEvent m_stopEvent = new ManualResetEvent(false);
    ManualResetEvent m_enqueuEvent = new ManualResetEvent(false);
    Thread m_processTask;

    List<ActionQueueItem> m_queue = new List<ActionQueueItem>();

    public ActionDelayQueue()
    {

    }

    public bool Start()
    {
        Stop();

        m_stopEvent.Reset();
        m_processTask = new Thread(Process);
        m_processTask.Start();
        return true;
    }

    public bool Stop()
    {
        if (m_processTask != null)
        {
            m_stopEvent.Set();
            if (!m_stopEvent.WaitOne(1000))
                m_processTask.Abort();

            m_processTask = null;
            return true;
        }

        return false;
    }

    public void Enqueue(ActionQueueItem item)
    {
        lock (m_queue)
        {
            if (item.Priority >= 5)
            {
                m_queue.Insert(0, item);
            }
            else
                m_queue.Add(item);
           
            m_enqueuEvent.Set();
        }
    }

    private void Process()
    {
        try
        {
            WaitHandle[] list = new WaitHandle[] { m_stopEvent, m_enqueuEvent };
            while (true)
            {
                var res = WaitHandle.WaitAny(list);
                if (0 == res)
                    break;
                else if (1 == res)
                {
                    ActionQueueItem action = null;
                    lock (m_queue)
                    {
                        if (m_queue.Count > 0)
                        {
                            var currentTime = DateTime.Now;
                            action = m_queue[0];
                            m_queue.RemoveAt(0);

                            if (m_queue.Count <= 0)
                                m_enqueuEvent.Reset();
                        }
                    }

                    if (action != null)
                    {
                        Thread.Sleep(action.Delay);
                        action.Operation();
                    }
                }
            }
        }
        catch (Exception e)
        {
            Trace.WriteLine(e.Message);
        }
    }
}
Programming

Improving Readability of Code By Redesigning Java a Bit (no pun intended)

The thin red line to follow through this post is to understand that correct behavior of any application should emerge from the code. Java has been around over 20 years now and it is still one the most popular programming languages in 2015. 620 more words

Java

Comic Cons in Your Library!

I recently wrote a guest post over at Cosplay, Comics, and Geek Culture in Libraries about the Mini Comic Con that my library hosted in January ( 733 more words

Programs

Dokumentasi 1: JSON Webservices Sederhana

Selama 2 tahun bekerja di bidang Android Programmer, keberadaan webservices sangat dibutuhkan untuk mempermudah komunikasi data antar platform (mobile,web, dan desktop). Alasan dibutuhkannya webservices ini karena bentuknya yang universal dan dapat dibaca oleh platform-platform tersebut dan pada posting kali ini saya pengen sharing sedikit bagaimana membuat JSON Webservices yang paling sederhana. 930 more words

Informasi Teknologi

The Flavour of Spite - Eleven

She responded so well, I am certain I am right. She dissociates so naturally it proves she is born for this. I struggled so much more than her, even given my relative youth, when Imogen began my trials. 857 more words

Horror